checkIncrementLimit static method
Increment Limit
If min
or max
is null
don't control and return true
Include max
and min
Implementation
// ignore: comment_references
///If [min] or [max] is [null] don't control and return true
///
///Include [max] and [min]
///
static bool checkIncrementLimit(String field, Map<String, dynamic> request,
{num? min, num? max}) {
if (request['\$inc'] != null) {
var parsedFieldName = parseField(field);
if (request['\$inc'][parsedFieldName] == null) return true;
if (!(request['\$inc'] is Map)) return true;
Map<String, dynamic> map = request['\$inc']
..updateAll((key, value) => MapEntry(parseField(key), value));
var inc = num.parse(map[parsedFieldName]);
if (max != null) {
if (min != null) {
return inc <= max && inc >= min;
} else {
return inc <= max;
}
} else {
if (min != null) {
return inc >= min;
}
}
}
return true;
}