upsertLocalDoc method
DTO
upsertLocalDoc({
- required String id,
- required UpsertDocDef<
DTO, MODEL> doc, - bool doNotifyListeners = true,
Upserts (updates or inserts) a document in local state.
This method will either update an existing document or create a new one
if it doesn't exist. The doc function receives the current document
(or null if it doesn't exist) and should return the new document state.
Parameters:
id- The ID of the document to upsertdoc- The definition of how to upsert the documentdoNotifyListeners- Whether to notify listeners of the change
Returns the upserted document
Implementation
@protected
DTO upsertLocalDoc({
required String id,
required UpsertDocDef<DTO, MODEL> doc,
bool doNotifyListeners = true,
}) {
log.debug('Upserting local doc with id: $id');
final pDoc = doc(tryFindById(id), vars(id: id));
docsNotifier.updateCurrent(
(value) => value..upsertDto(pDoc),
doNotifyListeners: doNotifyListeners,
);
return pDoc;
}