as you can see, any references to primary email is gone and it bacame undefined.
The similar thing happens if I try to assign object to _primary_email field, so this code does not work either:
models.User.findById(userId).exec().then(function (userModel) {
if (!userModel) {
throw new errors.UserNotFoundError();
}
models.Email.findById(userModel._primary_email).exec().then(function(emailModel) {
if (!emailModel) {
throw new errors.NotFoundError();
}
userModel._primary_email = emailModel;
console.log(props.userModel);
});
})
So, it is seen from this example the _primary_email filed still showing model _id instead of the actual object.
I tested this logic with ObjectId instead of UUID and it seems work as expected, so I think there may be something special about using UUID as a primary key. Any ideas?
mongo:
3.2.8
mongoose:4.5.9
I'm trying to use the mongoose-uuid2 package for primary keys in my database and here is my schema:
I managed to populate references saving
id
directly and I can see all correct entries in my database. However, if I do something like this:I can see this output:
which is correct. Next, I modify the query to populate
_primary_email
field like so:I get this object:
as you can see, any references to primary email is gone and it bacame
undefined
. The similar thing happens if I try to assign object to_primary_email
field, so this code does not work either:I get:
So, it is seen from this example the
_primary_email
filed still showing model _id instead of the actual object.I tested this logic with
ObjectId
instead ofUUID
and it seems work as expected, so I think there may be something special about using UUID as a primary key. Any ideas?