140 lines
4.8 KiB
Dart
140 lines
4.8 KiB
Dart
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
// This code was generated by ObjectBox. To update it run the generator again:
|
|
// With a Flutter package, run `flutter pub run build_runner build`.
|
|
// With a Dart package, run `dart run build_runner build`.
|
|
// See also https://docs.objectbox.io/getting-started#generate-objectbox-code
|
|
|
|
// ignore_for_file: camel_case_types
|
|
// coverage:ignore-file
|
|
|
|
import 'dart:typed_data';
|
|
|
|
import 'package:flat_buffers/flat_buffers.dart' as fb;
|
|
import 'package:objectbox/internal.dart'; // generated code can access "internal" functionality
|
|
import 'package:objectbox/objectbox.dart';
|
|
import 'package:objectbox_flutter_libs/objectbox_flutter_libs.dart';
|
|
|
|
import 'model.dart';
|
|
|
|
export 'package:objectbox/objectbox.dart'; // so that callers only have to import this file
|
|
|
|
final _entities = <ModelEntity>[
|
|
ModelEntity(
|
|
id: const IdUid(1, 2802681814019499133),
|
|
name: 'Note',
|
|
lastPropertyId: const IdUid(4, 6451339597165131221),
|
|
flags: 0,
|
|
properties: <ModelProperty>[
|
|
ModelProperty(
|
|
id: const IdUid(1, 3178873177797362769),
|
|
name: 'id',
|
|
type: 6,
|
|
flags: 1),
|
|
ModelProperty(
|
|
id: const IdUid(2, 4285343053028527696),
|
|
name: 'text',
|
|
type: 9,
|
|
flags: 0),
|
|
ModelProperty(
|
|
id: const IdUid(3, 2606273611209948020),
|
|
name: 'comment',
|
|
type: 9,
|
|
flags: 0),
|
|
ModelProperty(
|
|
id: const IdUid(4, 6451339597165131221),
|
|
name: 'date',
|
|
type: 10,
|
|
flags: 0)
|
|
],
|
|
relations: <ModelRelation>[],
|
|
backlinks: <ModelBacklink>[])
|
|
];
|
|
|
|
/// Open an ObjectBox store with the model declared in this file.
|
|
Future<Store> openStore(
|
|
{String? directory,
|
|
int? maxDBSizeInKB,
|
|
int? fileMode,
|
|
int? maxReaders,
|
|
bool queriesCaseSensitiveDefault = true,
|
|
String? macosApplicationGroup}) async =>
|
|
Store(getObjectBoxModel(),
|
|
directory: directory ?? (await defaultStoreDirectory()).path,
|
|
maxDBSizeInKB: maxDBSizeInKB,
|
|
fileMode: fileMode,
|
|
maxReaders: maxReaders,
|
|
queriesCaseSensitiveDefault: queriesCaseSensitiveDefault,
|
|
macosApplicationGroup: macosApplicationGroup);
|
|
|
|
/// ObjectBox model definition, pass it to [Store] - Store(getObjectBoxModel())
|
|
ModelDefinition getObjectBoxModel() {
|
|
final model = ModelInfo(
|
|
entities: _entities,
|
|
lastEntityId: const IdUid(1, 2802681814019499133),
|
|
lastIndexId: const IdUid(0, 0),
|
|
lastRelationId: const IdUid(0, 0),
|
|
lastSequenceId: const IdUid(0, 0),
|
|
retiredEntityUids: const [],
|
|
retiredIndexUids: const [],
|
|
retiredPropertyUids: const [],
|
|
retiredRelationUids: const [],
|
|
modelVersion: 5,
|
|
modelVersionParserMinimum: 5,
|
|
version: 1);
|
|
|
|
final bindings = <Type, EntityDefinition>{
|
|
Note: EntityDefinition<Note>(
|
|
model: _entities[0],
|
|
toOneRelations: (Note object) => [],
|
|
toManyRelations: (Note object) => {},
|
|
getId: (Note object) => object.id,
|
|
setId: (Note object, int id) {
|
|
object.id = id;
|
|
},
|
|
objectToFB: (Note object, fb.Builder fbb) {
|
|
final textOffset = fbb.writeString(object.text);
|
|
final commentOffset =
|
|
object.comment == null ? null : fbb.writeString(object.comment!);
|
|
fbb.startTable(5);
|
|
fbb.addInt64(0, object.id);
|
|
fbb.addOffset(1, textOffset);
|
|
fbb.addOffset(2, commentOffset);
|
|
fbb.addInt64(3, object.date.millisecondsSinceEpoch);
|
|
fbb.finish(fbb.endTable());
|
|
return object.id;
|
|
},
|
|
objectFromFB: (Store store, ByteData fbData) {
|
|
final buffer = fb.BufferContext(fbData);
|
|
final rootOffset = buffer.derefObject(0);
|
|
|
|
final object = Note(
|
|
const fb.StringReader(asciiOptimization: true)
|
|
.vTableGet(buffer, rootOffset, 6, ''),
|
|
id: const fb.Int64Reader().vTableGet(buffer, rootOffset, 4, 0),
|
|
comment: const fb.StringReader(asciiOptimization: true)
|
|
.vTableGetNullable(buffer, rootOffset, 8),
|
|
date: DateTime.fromMillisecondsSinceEpoch(
|
|
const fb.Int64Reader().vTableGet(buffer, rootOffset, 10, 0)));
|
|
|
|
return object;
|
|
})
|
|
};
|
|
|
|
return ModelDefinition(model, bindings);
|
|
}
|
|
|
|
/// [Note] entity fields to define ObjectBox queries.
|
|
class Note_ {
|
|
/// see [Note.id]
|
|
static final id = QueryIntegerProperty<Note>(_entities[0].properties[0]);
|
|
|
|
/// see [Note.text]
|
|
static final text = QueryStringProperty<Note>(_entities[0].properties[1]);
|
|
|
|
/// see [Note.comment]
|
|
static final comment = QueryStringProperty<Note>(_entities[0].properties[2]);
|
|
|
|
/// see [Note.date]
|
|
static final date = QueryIntegerProperty<Note>(_entities[0].properties[3]);
|
|
}
|