Cannot find a document by its "id"
Opened this issue · 0 comments
piglovesyou commented
When I try to find a document by its "id", the library gives me a runtime error. I'd like to know whether this is a bug or there is another right way. Thanks.
var Schema = require('jugglingdb').Schema;
var schema = new Schema('mongodb', {
host: 'localhost',
database: 'try_jugglingdb',
debug: true
});
var Chair = schema.define('Chair', {
id: String
});
Chair.create({
id: '__id__'
}, function(err, doc) {
// Error: Argument passed in must be a single String of 12 bytes or a string of 24 hex characters
Chair.find('__id__', function(err, doc) {
console.log(doc);
});
// Error: Argument passed in must be a single String of 12 bytes or a string of 24 hex characters
Chair.findOne({where: {id: '__id__'}}, function(err, doc) {
console.log(doc);
});
// OK.
Chair.findOne({where: {_id: '__id__'}}, function(err, doc) {
console.log(doc);
});
});
Versions:
- nodejs v0.10.32
- jugglingdb 0.3.0
- jugglingdb-mongodb 0.0.4-4