Hi! I'm struggling a bit with an include behavior I wouldn't expect.
I have a model A which has a belongsTo relation with model B.
A.findById(id, {"include":"b"}, function(err, data){
console.log(data);
console.log(data.b);
})
I have a model A which has a belongsTo relation with model B.
A.findById(id, {"include":"b"}, function(err, data){
console.log(data);
console.log(data.b);
})
On the first console.log I can actually see something like { b: { ... }, .... }, and it's properties but the second one will get me:
{ [Function: bound ]
getAsync: [Function: bound ],
update: [Function: bound ],
destroy: [Function: bound ],
create: [Function: bound ],
build: [Function: bound ],
_targetClass: 'B' }
Then if I try to console.log(data.b.xproperty) it will just return undefined when it was clearly shown on the console.log(data)
linux x64 7.4.0
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
@luisfavila Have a look on this - https://loopback.io/doc/en/lb3/Include-filter.html#access-included-objects
Try to do - data.toJSON() then access b
Most helpful comment
@luisfavila Have a look on this - https://loopback.io/doc/en/lb3/Include-filter.html#access-included-objects
Try to do - data.toJSON() then access b