between method

ConditionQuery between(
  1. dynamic min,
  2. dynamic max
)

Get db statement to check if this value is between two dates,

min and max may be DateTime object or DateTimeField

Implementation

ConditionQuery between(dynamic min, dynamic max) {
  DbFunctions.assertDateTimesValues([min, max]);
  var q = ConditionQuery();
  String qString = '(${buildQuery()} BETWEEN ';
  qString += (min is DateTimeField) ? min.buildQuery() : '?';
  qString += ' AND ';
  qString += (max is DateTimeField) ? max.buildQuery() : '?';
  qString += ')';
  q.queryBuilder = () => qString;
  q.parametersBuilder = () => [
        ...getParameters(),
        if (min is NumField)
          ...min.getParameters()
        else
          (min as DateTime).millisecondsSinceEpoch,
        if (max is NumField)
          ...max.getParameters()
        else
          (max as DateTime).millisecondsSinceEpoch
      ];
  return q;
}