Skip to content

Duplicate/cloned columns when generating table with mongodb query #6961

Discussion options

You must be logged in to vote

I am a complete idiot.
You simply have to add the "fields".
this is how the query looks now:

{
    "collection": "DATABASE_NORMALIZZATO",
    "fields":{
        "_id": 1,
        "TotalProducts": 1
    },
    "aggregate": [
        {
            "$group": {
                "_id": "$COSTRUTTORE | TITOLARE",
                "TotalProducts": {
                    "$sum": 1
                }
            }
        },
        {
            "$sort": [{
			"name": "TotalProducts",
			"direction": -1
		    }]
        }
    ]
}

and of course it works. I completely forgot you have to do that, lol. Reminder for anyone who might come across this: "fields" is like projection in mongodb.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@justinclift
Comment options

Answer selected by GabrielSalernoILARI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants