Created
May 2, 2011 00:55
-
-
Save chrishamant/951049 to your computer and use it in GitHub Desktop.
Sample of discrepancy between mongo db parsers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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