Closed scandar closed 3 years ago
i was trying to query a bunch of data for some analytics.
accessing the database directly with this query gets me the data i need
db.getCollection('orders').aggregate([ { $group : { _id :{ $dateToString: { format: "%Y-%m-%d", date: "$created_at"} }, count: { $sum: 1 }, total_price: { $sum: "$total_price" } } } ])
how exactly do i translate this to the ORM?
i know there's methods like count and sum but this forces me to do the same query twice instead of getting all the results in one query
also is there an equivalent for the aggregate function?
i was trying to query a bunch of data for some analytics.
accessing the database directly with this query gets me the data i need
how exactly do i translate this to the ORM?
i know there's methods like count and sum but this forces me to do the same query twice instead of getting all the results in one query
also is there an equivalent for the aggregate function?