createFindAndModifyCommand static method

DbCommand createFindAndModifyCommand(
  1. Db db,
  2. String collectionName, {
  3. Map<String, dynamic>? query,
  4. Map<String, dynamic>? sort,
  5. bool? remove = false,
  6. Map<String, dynamic>? update,
  7. bool? returnNew = false,
  8. Map<String, dynamic>? fields,
  9. bool? upsert = false,
})

Implementation

static DbCommand createFindAndModifyCommand(Db db, String collectionName,
    {Map<String, dynamic>? query,
    Map<String, dynamic>? sort,
    bool? remove = false,
    Map<String, dynamic>? update,
    bool? returnNew = false,
    Map<String, dynamic>? fields,
    bool? upsert = false}) {
  var command = <String, dynamic>{'findandmodify': collectionName};
  if (query != null) {
    command['query'] = query;
  }
  if (sort != null) {
    command['sort'] = sort;
  }
  if (remove != null && remove) {
    command['remove'] = remove;
  }
  if (update != null) {
    command['update'] = update;
  }
  if (returnNew != null && returnNew) {
    command['new'] = returnNew;
  }
  if (fields != null) {
    command['fields'] = fields;
  }
  if (upsert != null && upsert) {
    command['upsert'] = upsert;
  }
  return DbCommand(db, SYSTEM_COMMAND_COLLECTION,
      MongoQueryMessage.OPTS_NO_CURSOR_TIMEOUT, 0, -1, command, null);
}