Open michaeljota opened 8 years ago
This might be a bug, just need some more info.
Are you loading these two objects using the same query, options, etc? The more info the better. Or, if you have a bare-bones example of the problem in code, that would be best.
Thanks!
Hi! Sorry to being late answering. I'm not loading the first object, I'm creating it.
Creating:
var r = Room.create(req.body);
User.loadOne({_id: req.user._id})
.then((user) => {
r.owner = user;
r.clients.push(user);
var c = Classroom.create ({className: r.title});
var w = Whiteboard.create();
w.save()
.then((whiteboard) => {
c.whiteboards.push(w);
c.save()
.then((classroom) => {
r.classroom = c;
r.save()
.then((room) => {
successHandler (res, room);
})
.catch((err) => {
errorHandler (res, err);
});
})
.catch((err) => {
errorHandler (res, err);
});
})
.catch((err) => {
errorHandler (res, err);
})
})
.catch((err) => {
errorHandler (res, err);
});
Loading:
Room.loadOne({_id: req.params.roomId})
.then((room) => {
successHandler (res, room);
})
.catch((err) => {
errorHandler (res, err);
});
Again, if this is the expected behavior, I'm sorry. I know now the load of the others documents should be on my own without Camo, but maybe this is something Camo should do. Idk.
Looking at the object data from your first post, I think it's a bug. I should be able to look in to this further this weekend.
Thanks for posting the issue and your code!
Any word on this issue yet?
@devdebonair I think not. A workarround can be to load the other objects inside the load. I know it's not ideal, but, it will work.
When you create a new document, it gets return with all the reference as objects, but when it's loaded, only loades the ids.
Creating:
Loading:
Well, they both have the classroom, not just the reference, but the whiteboards (being a Array of Whiteboard documents) only load the id.
Is this the expected behavior? If it is, I'm sorry. I'm new with Document-oriented databases.
Thanks!