MongoDocument Class
MongoDocument
Constructor
MongoDocument
(
-
collection
-
doc
Parameters:
-
collection
MongoCollectionThe collection to work with
-
doc
ObjectDBObject document
Methods
toJSON
()
String
Serialize this document to JSON
Returns:
String:
JSON representation of the document
Properties
data
Object
Document object map
Example:
var col = mongo.connect().getDB('myDatabase').getCollection('myCollection');
var doc = col.findOne( { firstname: "John" } } );
doc.data.firstname === "John" // true