Mongodb sort the find query

well, i did some tests :nerd_face:
i found i have to use {“sort”:{“year”:-1, “id_month”:-1} } as argument for my sort purpose, but if i use {“sort”:{{data.query.s}} } as argument value, with data.query.s like &s={“year”:-1, “id_month”:-1}, it throws me an error or it doesn’t sort correctly. Dunno why.
I tried with string template but i didn’t find a way to format the argument value the right way i want to give me results.
I found that i can pass all the command as the argument, like &s={“sort”:{“year”:-1, “id_month”:-1} } , with the {“sort”: thing and it returns me the right data :partying_face:
I’m just a perfectionist and will try to avoid the “sort” thing passed by the argument, just need to find the right way, or if someone know what i’m doing wrong :robot:

1 Like