Skip to content

Instantly share code, notes, and snippets.

@myndzi
Created May 28, 2015 15:07
Show Gist options
  • Save myndzi/58471e4162792d550377 to your computer and use it in GitHub Desktop.
Save myndzi/58471e4162792d550377 to your computer and use it in GitHub Desktop.
Service.prototype.selectArray = function (query, column, asName) {
var formatter = new query.client.Formatter();
var fromStr = this.table + '.' + this.pkey;
var q = knex.select(column)
.from(this.table)
.whereRaw(formatter.wrap(this.idName) + ' = ' + formatter.wrap(fromStr));
return query.select( knex.raw(q).wrap('ARRAY(', ') AS ' + formatter.wrap(asName)) );
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment