|
|
@@ -9,7 +9,11 @@ import 'package:objectbox/internal.dart'; // generated code can access "internal
|
|
|
import 'package:objectbox/objectbox.dart';
|
|
|
import 'package:objectbox_flutter_libs/objectbox_flutter_libs.dart';
|
|
|
|
|
|
+import 'entities/content.dart';
|
|
|
+import 'entities/friend.dart';
|
|
|
+import 'entities/message.dart';
|
|
|
import 'entities/profile.dart';
|
|
|
+import 'entities/user.dart';
|
|
|
|
|
|
export 'package:objectbox/objectbox.dart'; // so that callers only have to import this file
|
|
|
|
|
|
@@ -17,7 +21,7 @@ final _entities = <ModelEntity>[
|
|
|
ModelEntity(
|
|
|
id: const IdUid(2, 1438354990151910015),
|
|
|
name: 'Profile',
|
|
|
- lastPropertyId: const IdUid(6, 4818206049188692305),
|
|
|
+ lastPropertyId: const IdUid(7, 4763561980566319174),
|
|
|
flags: 0,
|
|
|
properties: <ModelProperty>[
|
|
|
ModelProperty(
|
|
|
@@ -39,9 +43,114 @@ final _entities = <ModelEntity>[
|
|
|
id: const IdUid(4, 5923665807684456265),
|
|
|
name: 'isLogin',
|
|
|
type: 1,
|
|
|
+ flags: 0),
|
|
|
+ ModelProperty(
|
|
|
+ id: const IdUid(7, 4763561980566319174),
|
|
|
+ name: 'isLogout',
|
|
|
+ type: 1,
|
|
|
flags: 0)
|
|
|
],
|
|
|
relations: <ModelRelation>[],
|
|
|
+ backlinks: <ModelBacklink>[]),
|
|
|
+ ModelEntity(
|
|
|
+ id: const IdUid(3, 2132486004932842474),
|
|
|
+ name: 'Content',
|
|
|
+ lastPropertyId: const IdUid(1, 8861377786907255369),
|
|
|
+ flags: 0,
|
|
|
+ properties: <ModelProperty>[
|
|
|
+ ModelProperty(
|
|
|
+ id: const IdUid(1, 8861377786907255369),
|
|
|
+ name: 'id',
|
|
|
+ type: 6,
|
|
|
+ flags: 1)
|
|
|
+ ],
|
|
|
+ relations: <ModelRelation>[],
|
|
|
+ backlinks: <ModelBacklink>[]),
|
|
|
+ ModelEntity(
|
|
|
+ id: const IdUid(4, 5044745765388820377),
|
|
|
+ name: 'Friend',
|
|
|
+ lastPropertyId: const IdUid(3, 214180290351070734),
|
|
|
+ flags: 0,
|
|
|
+ properties: <ModelProperty>[
|
|
|
+ ModelProperty(
|
|
|
+ id: const IdUid(1, 5034484793468406763),
|
|
|
+ name: 'id',
|
|
|
+ type: 6,
|
|
|
+ flags: 1),
|
|
|
+ ModelProperty(
|
|
|
+ id: const IdUid(2, 754684519442805673),
|
|
|
+ name: 'user1Id',
|
|
|
+ type: 11,
|
|
|
+ flags: 520,
|
|
|
+ indexId: const IdUid(2, 3790366672903506902),
|
|
|
+ relationTarget: 'User'),
|
|
|
+ ModelProperty(
|
|
|
+ id: const IdUid(3, 214180290351070734),
|
|
|
+ name: 'user2Id',
|
|
|
+ type: 11,
|
|
|
+ flags: 520,
|
|
|
+ indexId: const IdUid(3, 1460593015267560936),
|
|
|
+ relationTarget: 'User')
|
|
|
+ ],
|
|
|
+ relations: <ModelRelation>[
|
|
|
+ ModelRelation(
|
|
|
+ id: const IdUid(1, 5078486750954543598),
|
|
|
+ name: 'messages',
|
|
|
+ targetId: const IdUid(5, 8880211362757189177))
|
|
|
+ ],
|
|
|
+ backlinks: <ModelBacklink>[]),
|
|
|
+ ModelEntity(
|
|
|
+ id: const IdUid(5, 8880211362757189177),
|
|
|
+ name: 'Message',
|
|
|
+ lastPropertyId: const IdUid(3, 7721473969164711791),
|
|
|
+ flags: 0,
|
|
|
+ properties: <ModelProperty>[
|
|
|
+ ModelProperty(
|
|
|
+ id: const IdUid(1, 8816894358087325317),
|
|
|
+ name: 'id',
|
|
|
+ type: 6,
|
|
|
+ flags: 1),
|
|
|
+ ModelProperty(
|
|
|
+ id: const IdUid(2, 7982216815340584307),
|
|
|
+ name: 'fromId',
|
|
|
+ type: 11,
|
|
|
+ flags: 520,
|
|
|
+ indexId: const IdUid(4, 6495021264194887400),
|
|
|
+ relationTarget: 'User'),
|
|
|
+ ModelProperty(
|
|
|
+ id: const IdUid(3, 7721473969164711791),
|
|
|
+ name: 'toId',
|
|
|
+ type: 11,
|
|
|
+ flags: 520,
|
|
|
+ indexId: const IdUid(5, 5329740598468773345),
|
|
|
+ relationTarget: 'User')
|
|
|
+ ],
|
|
|
+ relations: <ModelRelation>[],
|
|
|
+ backlinks: <ModelBacklink>[]),
|
|
|
+ ModelEntity(
|
|
|
+ id: const IdUid(6, 6066676571331973763),
|
|
|
+ name: 'User',
|
|
|
+ lastPropertyId: const IdUid(2, 2230815448876041069),
|
|
|
+ flags: 0,
|
|
|
+ properties: <ModelProperty>[
|
|
|
+ ModelProperty(
|
|
|
+ id: const IdUid(1, 5757871925438229578),
|
|
|
+ name: 'id',
|
|
|
+ type: 6,
|
|
|
+ flags: 1),
|
|
|
+ ModelProperty(
|
|
|
+ id: const IdUid(2, 2230815448876041069),
|
|
|
+ name: 'username',
|
|
|
+ type: 9,
|
|
|
+ flags: 2080,
|
|
|
+ indexId: const IdUid(6, 2181766053148811865))
|
|
|
+ ],
|
|
|
+ relations: <ModelRelation>[
|
|
|
+ ModelRelation(
|
|
|
+ id: const IdUid(2, 3118435353931894829),
|
|
|
+ name: 'friends',
|
|
|
+ targetId: const IdUid(4, 5044745765388820377))
|
|
|
+ ],
|
|
|
backlinks: <ModelBacklink>[])
|
|
|
];
|
|
|
|
|
|
@@ -65,9 +174,9 @@ Future<Store> openStore(
|
|
|
ModelDefinition getObjectBoxModel() {
|
|
|
final model = ModelInfo(
|
|
|
entities: _entities,
|
|
|
- lastEntityId: const IdUid(2, 1438354990151910015),
|
|
|
- lastIndexId: const IdUid(1, 2185831944762227781),
|
|
|
- lastRelationId: const IdUid(0, 0),
|
|
|
+ lastEntityId: const IdUid(6, 6066676571331973763),
|
|
|
+ lastIndexId: const IdUid(6, 2181766053148811865),
|
|
|
+ lastRelationId: const IdUid(2, 3118435353931894829),
|
|
|
lastSequenceId: const IdUid(0, 0),
|
|
|
retiredEntityUids: const [3444477729893015694],
|
|
|
retiredIndexUids: const [],
|
|
|
@@ -95,11 +204,12 @@ ModelDefinition getObjectBoxModel() {
|
|
|
final usernameOffset = object.username == null
|
|
|
? null
|
|
|
: fbb.writeString(object.username!);
|
|
|
- fbb.startTable(7);
|
|
|
+ fbb.startTable(8);
|
|
|
fbb.addInt64(0, object.id);
|
|
|
fbb.addInt64(1, object.theme);
|
|
|
fbb.addOffset(2, usernameOffset);
|
|
|
fbb.addBool(3, object.isLogin);
|
|
|
+ fbb.addBool(6, object.isLogout);
|
|
|
fbb.finish(fbb.endTable());
|
|
|
return object.id;
|
|
|
},
|
|
|
@@ -113,9 +223,126 @@ ModelDefinition getObjectBoxModel() {
|
|
|
..username =
|
|
|
const fb.StringReader().vTableGetNullable(buffer, rootOffset, 8)
|
|
|
..isLogin =
|
|
|
- const fb.BoolReader().vTableGet(buffer, rootOffset, 10, false);
|
|
|
+ const fb.BoolReader().vTableGet(buffer, rootOffset, 10, false)
|
|
|
+ ..isLogout =
|
|
|
+ const fb.BoolReader().vTableGet(buffer, rootOffset, 16, false);
|
|
|
+
|
|
|
+ return object;
|
|
|
+ }),
|
|
|
+ Content: EntityDefinition<Content>(
|
|
|
+ model: _entities[1],
|
|
|
+ toOneRelations: (Content object) => [],
|
|
|
+ toManyRelations: (Content object) => {},
|
|
|
+ getId: (Content object) => object.id,
|
|
|
+ setId: (Content object, int id) {
|
|
|
+ object.id = id;
|
|
|
+ },
|
|
|
+ objectToFB: (Content object, fb.Builder fbb) {
|
|
|
+ fbb.startTable(2);
|
|
|
+ fbb.addInt64(0, object.id);
|
|
|
+ fbb.finish(fbb.endTable());
|
|
|
+ return object.id;
|
|
|
+ },
|
|
|
+ objectFromFB: (Store store, ByteData fbData) {
|
|
|
+ final buffer = fb.BufferContext(fbData);
|
|
|
+ final rootOffset = buffer.derefObject(0);
|
|
|
+
|
|
|
+ final object = Content()
|
|
|
+ ..id = const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0);
|
|
|
|
|
|
return object;
|
|
|
+ }),
|
|
|
+ Friend: EntityDefinition<Friend>(
|
|
|
+ model: _entities[2],
|
|
|
+ toOneRelations: (Friend object) => [object.user1, object.user2],
|
|
|
+ toManyRelations: (Friend object) =>
|
|
|
+ {RelInfo<Friend>.toMany(1, object.id): object.messages},
|
|
|
+ getId: (Friend object) => object.id,
|
|
|
+ setId: (Friend object, int id) {
|
|
|
+ object.id = id;
|
|
|
+ },
|
|
|
+ objectToFB: (Friend object, fb.Builder fbb) {
|
|
|
+ fbb.startTable(4);
|
|
|
+ fbb.addInt64(0, object.id);
|
|
|
+ fbb.addInt64(1, object.user1.targetId);
|
|
|
+ fbb.addInt64(2, object.user2.targetId);
|
|
|
+ fbb.finish(fbb.endTable());
|
|
|
+ return object.id;
|
|
|
+ },
|
|
|
+ objectFromFB: (Store store, ByteData fbData) {
|
|
|
+ final buffer = fb.BufferContext(fbData);
|
|
|
+ final rootOffset = buffer.derefObject(0);
|
|
|
+
|
|
|
+ final object = Friend()
|
|
|
+ ..id = const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0);
|
|
|
+ object.user1.targetId =
|
|
|
+ const fb.Int64Reader().vTableGet(buffer, rootOffset, 6, 0);
|
|
|
+ object.user1.attach(store);
|
|
|
+ object.user2.targetId =
|
|
|
+ const fb.Int64Reader().vTableGet(buffer, rootOffset, 8, 0);
|
|
|
+ object.user2.attach(store);
|
|
|
+ InternalToManyAccess.setRelInfo(object.messages, store,
|
|
|
+ RelInfo<Friend>.toMany(1, object.id), store.box<Friend>());
|
|
|
+ return object;
|
|
|
+ }),
|
|
|
+ Message: EntityDefinition<Message>(
|
|
|
+ model: _entities[3],
|
|
|
+ toOneRelations: (Message object) => [object.from, object.to],
|
|
|
+ toManyRelations: (Message object) => {},
|
|
|
+ getId: (Message object) => object.id,
|
|
|
+ setId: (Message object, int id) {
|
|
|
+ object.id = id;
|
|
|
+ },
|
|
|
+ objectToFB: (Message object, fb.Builder fbb) {
|
|
|
+ fbb.startTable(4);
|
|
|
+ fbb.addInt64(0, object.id);
|
|
|
+ fbb.addInt64(1, object.from.targetId);
|
|
|
+ fbb.addInt64(2, object.to.targetId);
|
|
|
+ fbb.finish(fbb.endTable());
|
|
|
+ return object.id;
|
|
|
+ },
|
|
|
+ objectFromFB: (Store store, ByteData fbData) {
|
|
|
+ final buffer = fb.BufferContext(fbData);
|
|
|
+ final rootOffset = buffer.derefObject(0);
|
|
|
+
|
|
|
+ final object = Message()
|
|
|
+ ..id = const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0);
|
|
|
+ object.from.targetId =
|
|
|
+ const fb.Int64Reader().vTableGet(buffer, rootOffset, 6, 0);
|
|
|
+ object.from.attach(store);
|
|
|
+ object.to.targetId =
|
|
|
+ const fb.Int64Reader().vTableGet(buffer, rootOffset, 8, 0);
|
|
|
+ object.to.attach(store);
|
|
|
+ return object;
|
|
|
+ }),
|
|
|
+ User: EntityDefinition<User>(
|
|
|
+ model: _entities[4],
|
|
|
+ toOneRelations: (User object) => [],
|
|
|
+ toManyRelations: (User object) =>
|
|
|
+ {RelInfo<User>.toMany(2, object.id): object.friends},
|
|
|
+ getId: (User object) => object.id,
|
|
|
+ setId: (User object, int id) {
|
|
|
+ object.id = id;
|
|
|
+ },
|
|
|
+ objectToFB: (User object, fb.Builder fbb) {
|
|
|
+ final usernameOffset = fbb.writeString(object.username);
|
|
|
+ fbb.startTable(3);
|
|
|
+ fbb.addInt64(0, object.id);
|
|
|
+ fbb.addOffset(1, usernameOffset);
|
|
|
+ fbb.finish(fbb.endTable());
|
|
|
+ return object.id;
|
|
|
+ },
|
|
|
+ objectFromFB: (Store store, ByteData fbData) {
|
|
|
+ final buffer = fb.BufferContext(fbData);
|
|
|
+ final rootOffset = buffer.derefObject(0);
|
|
|
+
|
|
|
+ final object = User(
|
|
|
+ id: const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0),
|
|
|
+ username:
|
|
|
+ const fb.StringReader().vTableGet(buffer, rootOffset, 6, ''));
|
|
|
+ InternalToManyAccess.setRelInfo(object.friends, store,
|
|
|
+ RelInfo<User>.toMany(2, object.id), store.box<User>());
|
|
|
+ return object;
|
|
|
})
|
|
|
};
|
|
|
|
|
|
@@ -138,4 +365,59 @@ class Profile_ {
|
|
|
/// see [Profile.isLogin]
|
|
|
static final isLogin =
|
|
|
QueryBooleanProperty<Profile>(_entities[0].properties[3]);
|
|
|
+
|
|
|
+ /// see [Profile.isLogout]
|
|
|
+ static final isLogout =
|
|
|
+ QueryBooleanProperty<Profile>(_entities[0].properties[4]);
|
|
|
+}
|
|
|
+
|
|
|
+/// [Content] entity fields to define ObjectBox queries.
|
|
|
+class Content_ {
|
|
|
+ /// see [Content.id]
|
|
|
+ static final id = QueryIntegerProperty<Content>(_entities[1].properties[0]);
|
|
|
+}
|
|
|
+
|
|
|
+/// [Friend] entity fields to define ObjectBox queries.
|
|
|
+class Friend_ {
|
|
|
+ /// see [Friend.id]
|
|
|
+ static final id = QueryIntegerProperty<Friend>(_entities[2].properties[0]);
|
|
|
+
|
|
|
+ /// see [Friend.user1]
|
|
|
+ static final user1 =
|
|
|
+ QueryRelationToOne<Friend, User>(_entities[2].properties[1]);
|
|
|
+
|
|
|
+ /// see [Friend.user2]
|
|
|
+ static final user2 =
|
|
|
+ QueryRelationToOne<Friend, User>(_entities[2].properties[2]);
|
|
|
+
|
|
|
+ /// see [Friend.messages]
|
|
|
+ static final messages =
|
|
|
+ QueryRelationToMany<Friend, Message>(_entities[2].relations[0]);
|
|
|
+}
|
|
|
+
|
|
|
+/// [Message] entity fields to define ObjectBox queries.
|
|
|
+class Message_ {
|
|
|
+ /// see [Message.id]
|
|
|
+ static final id = QueryIntegerProperty<Message>(_entities[3].properties[0]);
|
|
|
+
|
|
|
+ /// see [Message.from]
|
|
|
+ static final from =
|
|
|
+ QueryRelationToOne<Message, User>(_entities[3].properties[1]);
|
|
|
+
|
|
|
+ /// see [Message.to]
|
|
|
+ static final to =
|
|
|
+ QueryRelationToOne<Message, User>(_entities[3].properties[2]);
|
|
|
+}
|
|
|
+
|
|
|
+/// [User] entity fields to define ObjectBox queries.
|
|
|
+class User_ {
|
|
|
+ /// see [User.id]
|
|
|
+ static final id = QueryIntegerProperty<User>(_entities[4].properties[0]);
|
|
|
+
|
|
|
+ /// see [User.username]
|
|
|
+ static final username = QueryStringProperty<User>(_entities[4].properties[1]);
|
|
|
+
|
|
|
+ /// see [User.friends]
|
|
|
+ static final friends =
|
|
|
+ QueryRelationToMany<User, Friend>(_entities[4].relations[0]);
|
|
|
}
|