Closed cryptiklemur closed 1 year ago
@aequasi what do you mean? DBRef or program relations?
DBRef, sorry that was fairly vague. Was to excited about a non-AR ODM haha
@aequasi i may add this feature at closest time if you really need it. But, what do you think about abstraction for $lookup
instead dbref and classic relations?
Havent actually read about $lookup
. Looks like its supported from 3.2 and up? Is that ok with you? Looks way better than using a dbref
@aequasi yep, mongodb supports $lookup
from 3.2 and this feature really faster than direct fetching data in classic way. But it may be hard a lot to code. However i'll add DBRef
support for mongot.
Would definitely love to see $lookup support, but dont need it asap
@aequasi let's talk about DBRef
. What do you think how it should working? Should DBRef fetched automatically or in async maner?
const doc = await OrderCollection.findOne({_id});
// fetch it automatic somewhere in internal
doc.user // available at one moment with its parent
// fetch by reference
const user = await doc.user.fetch()
// fetch by populate pattern
await doc.populate();
doc.user // available now
Or we could control it via decorators like this:
class Doc extends SchemaDocument {
@ref({auto: true})
user: User;
}
Could be done a couple ways. I like the decorator control. Thats handy.
Maybe also:
const doc = await OrderCollection.findOne({_id}, {populate: false});
doc.user // undefined;
Are references possible with this lib?