bguerout/jongo

$project{_id:0} not working as expected

mlhotellerie opened this issue · 1 comments

$project{_id:0} allow to remove the _id field with and aggregate operation.

But for instance :

        org.jongo.Aggregate aggregate = jongo.getCollection("countries")
            .aggregate("{$project:{_id:0, 'test':'$_id'}}");

        List<DBObject> output = new ArrayList<>();
        for (DBObject dbObject : aggregate.map((DBObject dbo) -> dbo)) {
            output.add(dbObject);
        }

output is [{"_id":"0000000000000000000000C1","test":"0000000000000000000000C1"},{"_id":"0000000000000000000000C2","test":"0000000000000000000000C2"},{"_id":"0000000000000000000000C3","test":"0000000000000000000000C3"},{"_id":"0000000000000000000000C4","test":"0000000000000000000000C4"},{"_id":"0000000000000000000000C5","test":"0000000000000000000000C5"}]

Although we asked to exclude _id

In fact it was a problem with Fongo, not Jongo.