best way to flatten across documents?

18 views
Skip to first unread message

Seung Chan Lim

unread,
Oct 16, 2014, 3:10:02 PM10/16/14
to mobile-c...@googlegroups.com
I don't know if this is even possible, but I'm curious.

What I want to do is basically cross-document flattening(merging). 

Say I have 5 documents

(DOC 1)
_jd : 1
name: people
members: [2,3]


(DOC 2)
_id: 2
name: John Doe
age: 25
comments: [4]


(DOC 3)
_id: 3
name: Jane Doe
age: 23
comments: [5]


(DOC 4)
_id : 4
content: "I love you Jane"


(DOC 5)
_id: 5
content: "I love you, too, John"
reply_to: 4


Say I want to, as quickly as possible, retrieve the content of all 5. (The entire content of the conversation between everyone in the db) What would be the best practice?

For example, is there a way to, in one shot, ask for all 5 documents given that there are links embedded?


slim

Jens Alfke

unread,
Oct 16, 2014, 4:02:15 PM10/16/14
to mobile-c...@googlegroups.com

On Oct 16, 2014, at 12:10 PM, Seung Chan Lim <djs...@gmail.com> wrote:

For example, is there a way to, in one shot, ask for all 5 documents given that there are links embedded?

No; you'll have to get them one by one. They're stored in separate rows in the database, so even if we had an API to get them together, it wouldn't be any faster.

There are some tricks you can use with views to aggregate together properties from related documents, but they may be overkill for your case. The best advice I can give now is to write your code the simple way first and see if it's fast enough.

—Jens
Reply all
Reply to author
Forward
0 new messages