MongoRepository icon indicating copy to clipboard operation
MongoRepository copied to clipboard

Referencing external documents, opposed to embedding.

Open AlBakerKY opened this issue 9 years ago • 3 comments

If I want to store document references instead of embedded documents, how would I best achieve that in the repo? For example, I want to have users that can share newspapers..so something like this, where people can keep references to their favorite newspapers.

class Newspaper:Entity { string Name; string Content; Data publishDate} 
class User:Entity { string LastName; List<Newspaper>newspapers; } 

But internally that List should be serialized to store references to newspapers inside user, not content.

How seamlessly can that be accomplished and should I manually be maintaining those references through in my derived repositories?

Should those references be through ObjectIDs or strings?

Thanks for any help.

Al

AlBakerKY avatar Jul 28 '16 15:07 AlBakerKY

Let me know if #15 helps you answer your question.

As to answer your "How seamlessly"; that depends on what your definition of seamless is I guess :wink:

RobThree avatar Jul 28 '16 15:07 RobThree

#15 does help, thank you. As far as storing references, should they be strings or objectIDs?

AlBakerKY avatar Aug 10 '16 01:08 AlBakerKY

It's up to you; nothing stopping you from using either way :wink:

RobThree avatar Aug 13 '16 00:08 RobThree