djongo icon indicating copy to clipboard operation
djongo copied to clipboard

Aggregating with mongo aggregate

Open keinagae opened this issue 4 years ago • 0 comments

Unable to call mongo_aggregate

Calling bellow code gives

'QuerySet' object has no attribute 'mongo_aggregate'

results=TickerHistory.objects.select_related("ticker").filter(ticker_symbol__in=tickers)
        aggregated_results=results.mongo_aggregate(
            [
                {
                    "$group": {
                        "_id":"$date",
                        "tickers":{
                            "$push":{
                                "symbol":"$ticker.symbol",
                                "close":"$close"
                            }
                        }
                    }
                }
            ]
        )

Traceback

keinagae avatar Aug 16 '21 14:08 keinagae