Just a simple ORM of MongoDB API.
这个东西还是非常好的嘛!—— Master Yeechan
和 Mongoose 各有千秋。—— orzFly
User = mabolo.model 'User',
username:
type: String
required: true
age:
type: Number
default: 18
password: String
User.findByName = (name, options...) ->
return @findOne name: name, options...
User::getName = ->
return @username
Token = mabolo.model 'Token',
code: String
User = mabolo.model 'User',
tokens: [Token]
User.create
name: 'jysperm'
.then (jysperm) ->
User.create
name: 'jysperm'
, (err, jysperm) ->
jysperm.modify (jysperm) ->
Q.delay(1000).then ->
jysperm.age = 19
.then ->