Storage of ordered child documents / values ​​in CouchDB / JSON?

What is the best way to store ordered documents in CouchDB?

Let's say I have 100 articles and I want to order them simply by placing them in the order that I like, or I have 10,000 images and I want them to be displayed in a specific order, except by date / category /etc. Is it better to store it at the parental level (page or album level) or child level (image / article)?

Should it be something like this:


{
    _id: myPage;
    articles: [myArticle14, myArticle5, myArticle2, myArticle20...];
}
or that:  

{
    _id: myArticle14;
    position: 1;
}

... where articles: [myArticle14, myArticle5, myArticle2, myArticle20...];are the _idactual article documents.

What are the advantages / disadvantages of each and which, in your opinion, is easier to use as the application grows?

+3
2

, , . "" - - . .

+1

.

: .

. , , , , , , .

: . , , startKey endkey, , .

: .

.

+1

Source: https://habr.com/ru/post/1725348/


All Articles