dresende / node-orm2

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

question: search by object field #604

Open phahulin opened 9 years ago

phahulin commented 9 years ago

Hi guys,

if I have a property of type "object" how can I search on it? e.g.

    db.define('Test', { id: { type: 'serial', key: true }, obj: { type: 'object' } });
    db.Test.create([ { obj: { a: 1, b: 2 } }, { obj: { a: 1, b: 3, c: 4 } }, { obj: { a: 4, b: 6 } }], function (err, tests) {});

how can I find all items with obj.a == 1? Things like db.find({ 'obj.a' == 1 }, function () {}) or db.find({ obj: { a: 1 } }, function () {}) produce incorrect sql queries.

Thanks!