Created
May 29, 2013 16:59
-
-
Save marclar/5671889 to your computer and use it in GitHub Desktop.
mongoose ObjectId != mongo ObjectId ??
This file contains hidden or 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 mongodb = require('mongodb'); | |
var mongoose = require('mongoose'); | |
var id = '51a11f2d4da20b020000000a'; | |
var mongooseId = new mongoose.Types.ObjectId(id); | |
var mongoId = new mongodb.ObjectID(id); | |
var logs = []; | |
if(mongoId == mongooseId){ | |
logs.push('mongoId == mongooseId'); | |
} | |
else{ | |
logs.push('mongoId != mongooseId'); | |
} | |
if(mongoId === mongooseId){ | |
logs.push('mongoId === mongooseId'); | |
} | |
else{ | |
logs.push('mongoId !== mongooseId'); | |
} | |
console.log(logs.join(', ')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For me, this outputs:
mongoId != mongooseId, mongoId !== mongooseId