forked from tower-archive/tower
-
Notifications
You must be signed in to change notification settings - Fork 0
snippets
Lance Pollard edited this page Apr 16, 2012
·
1 revision
Quick examples of how to do common things that are too [perhaps] specific to be included in the framework itself.
class App.Sequence extends Tower.Model
@field "value", type: "Integer"
# only works in mongodb, refactor later.
# collection.findAndModify(query, sort, update, options, callback)
@next: (name, callback) ->
@store().collection().findAndModify {_id: name}, [['_id','asc']], {"$inc": {value: 1}}, {upsert: true, new: true}, (error, record) =>
callback.call @, error, try record.value
undefined