Irrelon / ForerunnerDB

A JavaScript database with mongo-like query language, data-binding support, runs in browsers and hybrid mobile apps as a client-side DB or on the server via Node.js!
http://www.irrelon.com
721 stars 72 forks source link

$distinct only returns one document #226

Closed urossmerdelj closed 7 years ago

urossmerdelj commented 7 years ago

When using $distinct operator on a subfield/nested-field it always returns only one document, for instance:

let query = {
    $distinct: {
        Parent: {
            _id: 1
        }
    }
};

db.collection('col').find(query);

Only returns the first document it finds based on the query (I'm using the latest version 1.4.63).

Also for some reason $distinct operator doesn't work at all on the interactive demo page on FDB site (but it's using an older version of FDB 1.3.2).

Could you tell me if I'm using the operator in a wrong way or if it's a bug in FDB?

Irrelon commented 7 years ago

Hey there!

Could you provide the data you are using as well so we have a complete runnable example? If you could post with your insert JSON so we can run it directly against the data you are running against that would be great.

It may be a bug or it may be expected behaviour depending on the data :)

Irrelon commented 7 years ago

OK I put some tests together using mock data - the issue is a bug in ForerunnerDB. I have updated the $distinct operation handler to support sub-document distinct and rolled out a new build for you (1.4.67). Could you update to the latest version of ForeunnerDB and let me know if your issue is now fixed?

Cheers!

urossmerdelj commented 7 years ago

Thanks for a really fast response, much appreciated. Will test the new build as soon as possible and let you know.

urossmerdelj commented 7 years ago

I can confirm $distinct now works on sub-documents. Thanks again for a quick response and lightning fast new build!

Cheers :)