-
Notifications
You must be signed in to change notification settings - Fork 120
Random Code Snippets
Lance Pollard edited this page Sep 24, 2012
·
2 revisions
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