Closed SteffanDonal closed 7 years ago
Sorry for not getting back to you sooner.
No, unfortunately this is not possible at the moment. Camo can't load arbitrarily deep references for you. It is, however, on the list of features for the 2.0 release. Until then you'll have to manually load (populate()
) the references.
Let me know if you need anything else, otherwise feel free to close the issue. Thanks!
populate() {
var chain = Promise.resolve();
if (this.requests.length > 0 && typeof this.requests[0] === 'string') {
chain = chain.then(() => super.populate());
}
return chain
.then(() => Promise.all(this.requests.map(request => request.populate())))
.then(() => this);
}
This is roughly what I ended up doing - this is an instance method defined on the Playlist
. It'll populate the list of requests, then for each one it'll populate the data inside that request.
I'm loving Camo so far, very clean and concise for what I need it for.
However I'm running into an issue where I'm loading a
Document
that contains an array ofDocument
s, each of which has a single reference to anotherDocument
.For example:
Playlist > QueuedSongs[] > Song
Currently when I retrieve the
Playlist
I then need to do aplaylist.queuedSongs.forEach(qSong => qSong.populate());
which isn't ideal as it produces more cruft.Is there a method to do this that I'm missing?