containedBy method

PostgrestFilterBuilder containedBy(
  1. String column,
  2. dynamic value
)

Finds all rows whose json, array, or range value on the stated column is contained by the specified value.

postgrest.from('users').select().containedBy('age_range', '[1,2)')

Implementation

PostgrestFilterBuilder containedBy(String column, dynamic value) {
  if (value is String) {
    // range types can be inclusive '[', ']' or exclusive '(', ')' so just
    // keep it simple and accept a string
    appendSearchParams(column, 'cd.$value');
  } else if (value is List) {
    // array
    appendSearchParams(column, 'cd.(${_cleanFilterArray(value)})');
  } else {
    // json
    appendSearchParams(column, 'cd.${json.encode(value)}');
  }
  return this;
}