geddy / model

Datastore-agnostic ORM in JavaScript
265 stars 55 forks source link

Query 'in' with array of IDs #233

Open lesterzone opened 9 years ago

lesterzone commented 9 years ago

With latest versiion 13.0.7,

A has many B, B belongs to A.

/**
 * All I need is get all A related to array of B ids
 */
var ids = ['id1', 'id2'];

A.all({
    id: {
        'in': ids
    }
}, function(err, data) {
    console.log(err, data); // null, []
});

var usernames = ['a', 'b'];
A.all({
    username: {
        'in': usernames
    }
}, function(err, data) {
    /**
     * It works!
     */
});