replace method

StringField replace(
  1. String pattern,
  2. dynamic replacement
)

Get db string field with replaced string.

pattern is the string to be replaced.

replacement is the string to replace the pattern, replacement may be StringField or String

Implementation

StringField replace(String pattern, dynamic replacement) {
  assert(replacement is String || replacement is StringField);

  var result = StringField();
  result.queryBuilder = () => replacement is StringField
      ? 'REPLACE(${buildQuery()},?,${replacement.buildQuery()})'
      : 'REPLACE(${buildQuery()},?,?)';
  result.parametersBuilder = () => getParameters()
    ..addAll([pattern, if (replacement is String) replacement]);
  return result;
}