Skip to content

Commit

Permalink
Documentation fix
Browse files Browse the repository at this point in the history
  • Loading branch information
christkv committed Jan 2, 2012
1 parent 0631f91 commit a1307fb
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Readme.md
Expand Up @@ -52,17 +52,18 @@ To store and retrieve the non-JSON MongoDb primitives ([ObjectID](http://www.mon

In particular, every document has a unique `_id` which can be almost any type, and by default a 12-byte ObjectID is created. ObjectIDs can be represented as 24-digit hexadecimal strings, but you must convert the string back into an ObjectID before you can use it in the database. For example:

// Get the objectID type
var ObjectID = require('mongodb').ObjectID;

// Get the objectID type
var ObjectID = require('mongodb').ObjectID;
var idString = '4e4e1638c85e808431000003';
collection.findOne({_id: new ObjectID(idString)}, console.log) // ok
collection.findOne({_id: idString}, console.log) // wrong! callback gets undefined

Here are the constructors the non-Javascript BSON primitive types:

// Fetch the library
var mongo = require('mongodb');
// Fetch the library
var mongo = require('mongodb');
// Create new instances of BSON types
new mongo.Long(numberString)
new mongo.ObjectID(hexString)
Expand Down

0 comments on commit a1307fb

Please sign in to comment.