Closed Grrravity closed 3 years ago
found and feels like documentation is lacking explanations x) You have to use customCode like this :
const tableA = SqfEntityTable(
tableName: 'table_a',
modelName: 'TableA',
primaryKeyName: 'uuid',
primaryKeyType: PrimaryKeyType.text,
fields: [
SqfEntityField('long', DbType.real),
SqfEntityField('lat', DbType.real),
SqfEntityField('text', DbType.text, isNotNull: true),
SqfEntityField('created_at', DbType.datetime),
SqfEntityField('updated_at', DbType.datetime),
SqfEntityField('deleted_at', DbType.datetime),
SqfEntityFieldRelationship(
parentTable: yyy,
deleteRule: DeleteRule.CASCADE,
fieldName: 'yyy_uuid',
isNotNull: true),
SqfEntityFieldRelationship(
parentTable: zzz,
deleteRule: DeleteRule.CASCADE,
fieldName: 'zzz_uuid',
isNotNull: true),
SqfEntityFieldRelationship(
parentTable: www,
deleteRule: DeleteRule.CASCADE,
fieldName: 'www_uuid'),
],
customCode: '''
createSync(TableA element) async {
await element.save();
var someThing = await TableY().select().top(1).toSingle();
String uuid = someThing?.uuid ?? '';
TableSync syncElement = TableSync(
uuid: uuidGen.v4(),
table_name: 'table_a',
target_uuid: element.uuid,
action: 'CREATE',
created_at: element.created_at,
updated_at: element.updated_at,
other_uuid: uuid);
await syncElement.save();
}
''');
Also there are some features like implementing your class to models or adding a preSaveAction method that invented by @ReniDelonzek Just take a look here: https://pub.dev/packages/sqfentity_gen/changelog#2102
Hi there, I'm facing a need and I can't figure how to satisfy with the current setup Got my local DB, which is a copy of my remote DB, and in it there's an "update" table where I'd like to put CRUD actions done offline to push to remote when network's available.
etc etc...
My question is: Is there a way to override C
RUD methods from generated model.g.dart to add a line in that update table when an action is done on any other tables.If I were the only dev working on this project I would make sure to add an extra Update(blablabla).save() after each crud but I'd like to make this extra action global so we're 100% sure it will be done :)
Thanks for your help !