dresende / node-orm2

Object Relational Mapping
http://github.com/dresende/node-orm2
MIT License
3.07k stars 379 forks source link

Chaining .omit and .get(1) #572

Open Vinze opened 9 years ago

Vinze commented 9 years ago

I'm trying to fetch a single user (without password) from the database, but having some trouble understanding how to accomplisch this.

// Doesn't work
User.omit('password').get(1, function(err, user) {
    res.json(user);
});

// Doesn't work either
User.get(1).omit('password').run(function(err, user) {
    res.json(user);
});

// Does work, but looks overcomplicated
User.find({ id: 1 }).omit('password').run(function(err, user) {
    res.json(user[0]);
});

What's the right way to do this?

syzer commented 9 years ago

Last one is quite clean. Very verbose.