like function

LikeCondition like(
  1. String pattern, [
  2. String? escape
])

Used in the whereValues of DBAccess.loadBy, DBAccess.queryBy, and sqlWhereBy to indicate a LIKE clause. That is, it shall be generated with field in (value1, value2)

Example,

await access.queryBy(..., {"name": like('a%z')});
  • escape the escape character. Specify it as '!' if a portion of pattern has been encoded with encodeTextInLike. For example,

    await access.queryBy(..., {"name": like('${encodeTextInLike(text)}%'), '!')})

Assume text is 'a%b', then it generates

...like 'a!%b%' escape '!'

Also note, if escape is specified, pattern is assumed to be encoded properly. That is, sqlWhereBy won't encode it again. See #10.

See also not and notIn.

Implementation

LikeCondition like(String pattern, [String? escape])
=> LikeCondition(pattern, escape);