Skip to content

Instantly share code, notes, and snippets.

@sdepold
Created September 19, 2012 18:21
Show Gist options
  • Save sdepold/3751260 to your computer and use it in GitHub Desktop.
Save sdepold/3751260 to your computer and use it in GitHub Desktop.
var options = db.define('options',
{
type: s.STRING,
type_id: s.INTEGER,
sort: s.INTEGER,
deleted: s.BOOLEAN,
hidden: s.BOOLEAN,
field1: s.STRING,
field2: s.STRING,
field3: s.STRING,
field4: s.STRING,
field5: s.STRING
},
{
classMethods: {
order_statuses: function() {
return this.findAll({where: {type: 'order_status', hidden: false},
order: 'sort ASC'})
},
item_statuses: function() {
return this.findAll({
where: {type: 'order_item_status', hidden: false},
order: 'sort ASC'
})
}
}
}
})
var chain = new model.__seq.Utils.QueryChainer();
chain
.add(model.options.item_statuses())
.add(model.options.order_statuses())
.add(model.partner_objects.findAll({where: {partner_id:
req.app.settings.partner.id, type: req.app.settings.partner.object},
order: 'name ASC'}))
.run()
.success(function(data) {
console.log(data[0]) // item statuses
console.log(data[1]) // order statuses
console.log(data[2]) // partner objects
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment