createFindAndModifyCommand static method
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,
})
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);
}