Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find a document by its "id" #30

Open
piglovesyou opened this issue Nov 10, 2014 · 0 comments
Open

Cannot find a document by its "id" #30

piglovesyou opened this issue Nov 10, 2014 · 0 comments

Comments

@piglovesyou
Copy link

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
@piglovesyou piglovesyou changed the title Cannot find a document by its id Cannot find a document by its "id" Nov 10, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant