Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
ObjectId instantiation error
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
cris  
View profile  
 More options Sep 24 2012, 7:18 pm
From: cris <gmc...@gmail.com>
Date: Mon, 24 Sep 2012 16:18:41 -0700 (PDT)
Local: Mon, Sep 24 2012 7:18 pm
Subject: ObjectId instantiation error

Hi all. I'm using the mongojs wrapper around mongodb node driver, and when
i try to create a client-side id with *new ObjectId()* i get an error
saying *the argument must be a single string of 12 bytes or a string of 24
hex characters*, so it seems that the ObjectId constructor is requiring an
_id argument, but the api docs specify that without arguments ObjectId will
create a new _id instance. What may be the issue here?

Thanks.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
cris  
View profile  
 More options Sep 24 2012, 7:24 pm
From: cris <gmc...@gmail.com>
Date: Mon, 24 Sep 2012 16:24:53 -0700 (PDT)
Local: Mon, Sep 24 2012 7:24 pm
Subject: Re: ObjectId instantiation error

Here's the code:

var  db = require('mongojs');
var dbd = db.connect('testdb');

var id = new db.ObjectId();

dbd.collection('docs').count( function (err, doc) {
        dbd.collection('docs').insert({"_id": id, "title": "My title",
"content": "My content", function (err, doc) {
                if (err) {console.log(err);}
            });
        console.log('obj literal load to MongoDB');


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
christkv  
View profile  
 More options Sep 25 2012, 7:23 am
From: christkv <chris...@gmail.com>
Date: Tue, 25 Sep 2012 04:23:07 -0700 (PDT)
Local: Tues, Sep 25 2012 7:23 am
Subject: Re: ObjectId instantiation error

better log this as an issue in the github tracker as it's not a driver issue


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
cris  
View profile  
 More options Sep 25 2012, 3:28 pm
From: cris <gmc...@gmail.com>
Date: Tue, 25 Sep 2012 12:28:25 -0700 (PDT)
Local: Tues, Sep 25 2012 3:28 pm
Subject: Re: ObjectId instantiation error

Yes, it´s a mongojs issue; suits me for not reading their docs carefully
where they state that mongojs try to emulate mongodb native driver "as much
as possible". Here's the code where they implement ObjectId instantiation:

var createObjectId = function() {
        if (!mongo.BSONNative || !mongo.BSONNative.ObjectID) {
          return function(id) {
                return mongo.BSONPure.ObjectID.createFromHexString(id);
          };
        }
        return function(id) {
                return new mongo.BSONNative.ObjectID(id);
        };


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »