1602 / jugglingdb

Multi-database ORM for nodejs: redis, mongodb, mysql, sqlite3, postgresql, arango, in-memory...
http://1602.github.io/jugglingdb/
2.04k stars 241 forks source link

Relations.js issue when using MongoDB adapter. #334

Closed origin1tech closed 10 years ago

origin1tech commented 10 years ago

Seems as though the following in the "belongsTo" method may need to be the culprit.

       if (inst.id=== this[fk]) {
            cb(null, inst);
        } else {
            cb(new Error('Permission denied'));
        }

The "hasMany" method converts to string before checking equality. if the above is changed to:

      inst.id.toString() === this[fk].toString()