Aggregating vars into one sort object


#1

Hi,
assuming I have two sessions vars:
var a = Session.get(‘sortFirst’) // {itemPrice: 1})
var b = Session.get(‘sortLast’) // {deliveryPrice: 1})
which I want dynamically insert into the sort query:
collection.find({}, {sort: a+b}; //or sort: a+ ‘,’ + b not showing any results. each query works separately.
what is the syntex to do it?

Thanks.


#2

https://docs.mongodb.com/manual/reference/operator/aggregation/sort/