select method

PostgrestTransformBuilder select([
  1. String columns = '*'
])

Performs horizontal filtering with SELECT.

postgrest.from('users').select('id, messages');

Implementation

PostgrestTransformBuilder select([String columns = '*']) {
  // Remove whitespaces except when quoted
  var quoted = false;
  final re = RegExp(r'\s');
  final cleanedColumns = columns.split('').map((c) {
    if (re.hasMatch(c) && !quoted) {
      return '';
    }
    if (c == '"') {
      quoted = !quoted;
    }
    return c;
  }).join();

  appendSearchParams('select', cleanedColumns);
  return this;
}