edwinjhlee/mongo-hacker

New query design

Opened this issue · 0 comments

Original Mongo Query

db.col.find({ a:{ $gt: 10 }}, { name:0, _id:0 })

With Query Builder

find(db.col).ignore("name", "_id").where(function(e){ return e.a > 10 }).exec()
find(db.col).ignore("name", "_id").where({ a:{ $gt: 10 } }).exec()

abbreviation

f(db.col).i("name", "_id").w(function(e){ return e.a > 10 }).e()
f(db.col).i("name", "_id").w({ a:{ $gt: 10 } }).e()

f(db.col).i("name", "_id").w(e => e.a > 10 ).e()

multi-line with implicit underscope

find(db.col).ignore("name", "_id")
_.where(function(e){ return e.a > 10 })
_.exec()

Builder step by step control