Skip to content

Instantly share code, notes, and snippets.

@kissmygritts
Created August 25, 2017 02:25
Show Gist options
  • Save kissmygritts/640085effc5063e010f4ba00abec73d7 to your computer and use it in GitHub Desktop.
Save kissmygritts/640085effc5063e010f4ba00abec73d7 to your computer and use it in GitHub Desktop.
ColumnSet help
'use strict'
const sql = require('../sql').elements
const helpers = require('pg-promise')().helpers
const cs = new helpers.ColumnSet([
'?id',
{
name: 'animal_id'
}, {
name: 'species_id'
}, {
name: 'sex',
def: 'unk'
}
], {table: { table: 'elements' }})
class Elements {
constructor (db, pgp) {
this.db = db
this.pgp = pgp
this.cs = cs || pgp.helpers.ColumnSet([
'?id',
{
name: 'animal_id'
}, {
name: 'species_id'
}, {
name: 'sex',
def: 'unk'
}
], {table: { table: 'elements' }})
}
all () {
return this.db.many(sql.all)
}
}
module.exports = Elements
@vitaly-t
Copy link

vitaly-t commented Aug 25, 2017

'use strict'
const sql = require('../sql').elements

let cs;

class Elements {
  constructor (db, pgp) {
    this.db = db
    this.pgp = pgp
    cs = cs || pgp.helpers.ColumnSet([
      '?id', 'animal_id', 'species_id',
       {
        name: 'sex',
        def: 'unk'
      }
    ], {table: { table: 'elements' }})
  }

  all () {
    return this.db.many(sql.all)
  }
}

module.exports = Elements

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment