Skip to content

Instantly share code, notes, and snippets.

@mizchi
Created April 19, 2014 05:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mizchi/11074676 to your computer and use it in GitHub Desktop.
Save mizchi/11074676 to your computer and use it in GitHub Desktop.
db = new Momic.DB
name: 'app'
collections:
items:
itemType: String
name: String
value: Number
db.items.drop().then =>
a = db.items.insert({ itemType: 'weapon', name: 'ひのきのぼう', value: 10})
b = db.items.insert([
{ itemType: 'weapon', name: 'てつのつるぎ', value: 50}
{ itemType: 'weapon', name: 'はがねのつるぎ', value: 120}
])
Promise.all(a,b).then =>
console.log db.items.count() #=> 3
db.items.findOne({name: 'てつのつるぎ'}).done (item) => console.log item
db.items.find({value: {'$gte':30}}).done (items) =>
db.drop({value: {'$gte':30}}).done (items) => console.log items
# db.items.remove(items).then =>
console.log 'items that has value more thant 30 area removed'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment