saveLocal method
Saves model of type T
in local storage.
By default notifies this modification to the associated CoreNotifier.
Implementation
T saveLocal(T model, {bool notify = true}) {
if (model._key == null) {
throw Exception("Model must be initialized:\n\n$model");
}
final key = model._key!.detypifyKey()!;
final map = serializeLocal(model, withRelationships: false);
final data = jsonEncode(map);
db.execute(
'REPLACE INTO $internalType (key, data) VALUES (?, ?)', [key, data]);
if (notify) {
core._notify([model._key!], type: DataGraphEventType.updateNode);
}
return model;
}