checkByFixedFields static method
Only Use Update Operation
Implementation
static bool checkByFixedFields(List<String> fields,
Map<String, dynamic> resource, Map<String, dynamic> request) {
/// Request {
/// '$inc' : {
/// 'field.subfield1.subfield2...' : 2
/// }
/// }
for (var op in request.keys) {
/// If update operation key not start update operations
/// Request denied
///
/// Mongo Db Update Operations Documentation :
/// https://docs.mongodb.com/manual/reference/operator/update/
///
if (op.startsWith('\$')) {
// ignore: avoid_as
var operation = request[op];
Iterable<String> opFields = operation.keys;
for (var operationFieldRaw in opFields) {
/// If update operation field key contains fixed keys
/// Request denied
if (fields.contains(operationFieldRaw)) {
return false;
}
}
} else {
return false;
}
}
/// In Default return true
return true;
}