insert method
Inserts a new document into the specified collection.
If optimistic is true and the document contains an _id, the local cache
is updated immediately with the new document while awaiting server
confirmation.
Implementation
Future<void> insert(
String collection,
JsonMap document, {
bool optimistic = false,
}) async {
final payload = _deepCopyMap(document);
if (optimistic && payload['_id'] != null) {
_queryManager.optimisticInsert(collection, payload);
}
await _webSocketService.send({
'type': 'realtime:insert',
'collection': collection,
'document': payload,
});
}