Skip to content

Instantly share code, notes, and snippets.

@chrishamant
Created May 2, 2011 00:55
Show Gist options
  • Save chrishamant/951049 to your computer and use it in GitHub Desktop.
Save chrishamant/951049 to your computer and use it in GitHub Desktop.
Sample of discrepancy between mongo db parsers
var Db = require('mongodb').Db;
var Server = require('mongodb').Server;
var Connection = require('mongodb').Connection;
var host = process.env['MONGO_NODE_DRIVER_HOST'] != null ? process.env['MONGO_NODE_DRIVER_HOST'] : 'localhost';
var port = process.env['MONGO_NODE_DRIVER_PORT'] != null ? process.env['MONGO_NODE_DRIVER_PORT'] : Connection.DEFAULT_PORT;
var nativeparser = new Db('testing', new Server(host, port, {}), {native_parser:true});
var jsparser = new Db('testing', new Server(host, port, {}));
var Foo = function(){
this.foo = "foo";
this.bar = "bar";
}
Foo.prototype = {
test : function(){
//this property shouldn't be in database
},
chicken : "nuggets" //makes sense for this to be in serialization
}
nativeparser.open(function(err, db) {
db.collection('test', function(err, collection) {
collection.insert(new Foo(),function(){
db.close();
});
});
});
jsparser.open(function(err, db) {
db.collection('test', function(err, collection) {
collection.insert(new Foo(),function(){
db.close();
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment