S
S
Siricks932020-03-04 23:27:15
MongoDB
Siricks93, 2020-03-04 23:27:15

How to sort documents in mongo?

There is a collection of documents like:
{"BookName":"War and peace I", "theme": "war", "author":"Tolstov"},
{"BookName":"War and peace II", "theme": "peace", "author":"Tolstov"}, "BookName":"War and peace |II", "theme": "peace", "author":"Tolstov"},
Is it possible to get sorted selection results in the form two-dimensional array:
["Tolstoy" => ["war"=>1, "peace"=>2]]

I.e. so that at the first level there are arrays with keys - authors, and inside arrays with a topic - the number of its repetitions?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question