Reference document doesn't populate data
See original GitHub issuevar color = ottoman.model('Color', {
value : {
type : "string"
}
})
var Furniture = ottoman.model('Fur', {
type: { type: 'string' },
color : { ref : 'Color' }
}
)
var c = new color({ value : "777777" });
c.save(function(err, doc){
if(!err) {
var test = new Furniture({
type : 'couch',
color : c
})
test.save(function(err, doc){
console.log(test);
})
}
})
Furniture.find({}, function(err, doc){
console.log('doc', doc[0].color);
})
the first logging show the color console.log(test);
as // { value : 77777 }
OttomanModel(`Fur`, loaded, key:Fur|6ace0a3e-9465-4c26-a699-6ba6a7b1a995, {
_id: '6ace0a3e-9465-4c26-a699-6ba6a7b1a995',
type: 'couch',
color: OttomanModel(`Color`, loaded, key:Color|64f8ac67-a334-4cf6-aa59-67c16a2cf3e2, {
_id: '64f8ac67-a334-4cf6-aa59-67c16a2cf3e2',
value: '777777',
}),
})
the second logging console.log('doc', doc[0].color);
show the color object but no data show up
_id: '2ccf7aee-9f3e-45d0-b6da-fa003ab405ab',
type: 'couch',
color: OttomanModel(`Color`, unloaded, key:Color|0d4b1f7b-e4d9-4ee2-bc31-67c208d23b89, {}),
I notice the first call the color model is loaded, but i don’t understand why it is not loaded when using find.
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Document property doesn't populate data in MS Word Online
Solved: Hello All, I have this requirement of generating a Word Document when an item in a list is created.
Read more >Solve issues with EndNote references in a document
Open a blank Word document and insert a few references. If the problem persists even in your new document, your problem is more...
Read more >EndNote: Updating a Word document to match changes from ...
When changes made to an EndNote™ library are not being reflected in your document, try to format the bibliography in the document.
Read more >Cloud Firestore Data model - Firebase
A reference is a lightweight object that just points to a location in your database. You can create a reference whether or not...
Read more >Repeating Data (Populating Multiple Like Fields) - Greg Maxey
On-line forms are Word documents that have "fill in the blanks. ... Bonus Tip: Use of the field name REF is optional in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just to add to @moxious’s answer. You can actually implicit load more of the submodels through various tools. You can pass the ‘load’ option to
.find
to specify specific paths to load (ie:.find({}, {load: ['color']})
. You can also pass the ‘depth’ option to load all models up to a certain depth.P.S. @moxious, recursive loading is supported. A->B->A will make B’s reference to A point to the actual model instance it already loaded as part of that
.load
call.Cheers, Brett
Yes, I was thinking that with the load option, ottoman load the definitions of the models from some place, but i reviewed the code and I see my mistake.