-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.id returns string while ._id returns object. is this a bug? #548
Comments
What I'm wondering is whether |
yes @donpark is correct. ObjectIds contain the raw MongoDB binary and don't work with templating so we provide the This is the flow we are making simpler: MongoDB -> ObjectId -> cast toHexString -> form -> submit -> cast from hexString -> ObjectId -> MongoDB |
wait, does it mean that we can't use a property "id" in our Schemas? I'm using my own "id" implementation as well |
@c4milo you can use your own |
nice, tks |
@aheckmann I am also using my own id (a string guid). recently I started receiving this error: Named property 'id' of types 'IMaintenance' and 'Document' are not identical. Any idea what might cause it? Is it related to the current issue? |
In the following function, test1 is a string because the virtual path runs through a different codeset and runs the toString() function, whereas test2 is an object with the 'id' set to the hex id. The console.log will produce the same result since console.log will call the .toString function in the object. However, I was under the impression .id and ._id were supposed to be the same thing. Which one am I supposed to be using or is this a bug?
function createSegment(options, callback){
var location = options.location;
var newSegment = new Segment({coordinates: new Array(location)});
newSegment.save(function(err){
if(err) {callback(err); return;}
debugger;
var test1 = newSegment.id;
var test2 = newSegment._id;
console.log(newSegment.id);
console.log(newSegment._id);
callback(null, newSegment.id);
});
}
The text was updated successfully, but these errors were encountered: