M
M
Maxim Barulin2013-01-27 08:55:15
PHP
Maxim Barulin, 2013-01-27 08:55:15

regular sql distinct in mongo

Good day habr!
I'm on the verge of writing my own bike. We need to fetch a set of unique records from mongo, but at the same time we need to return the entire documents, and not just the values ​​of the specified key. In the mongo manual ( docs.mongodb.org/manual/reference/command/distinct/ ) and the php manual on mongo classes ( php.net/manual/ru/mongocollection.distinct.php ), I did not find such an opportunity (maybe bad or not looking there?). It's hard to believe that you can't get the standard output of various documents.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rumka, 2013-01-27
@Rumka

This is because sql has nothing to do with it and there is no need to stretch the methods of one paradigm to another.
{firstname:"John",lastname:"Doe"}
{firstname:"John",lastname:"Doe",dead:true} Are they
the same documents? Or different? In mongo, there is no data schema in the database, so all the processing work falls on the shoulders of the programmer. Either solve the problem with the available means, or reformulate it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question