set method

Future<WriteResult> set(
  1. Map<String, dynamic> doc, {
  2. bool upset = true,
})

this will remove the old document and add another one with the same id

Implementation

Future<WriteResult> set(
  Map<String, dynamic> doc, {
  bool upset = true,
}) async {
  var deleteRes = await delete();
  if ((deleteRes.failure || deleteRes.isFailure) && !upset) {
    return deleteRes;
  }
  doc['_id'] = _id;
  return _collRef.insertOne(doc);
}