How to use MongoDB aggregate in Moleculer

248 Views Asked by At

I am new to moleculer framework. I want to use MongoDB's aggregate with moleculer framework it is possible ? Can anybody tell me how to write MongoDb's aggregate query in moleculer framework. Thanks in advance.

1

There are 1 best solutions below

0
On

It is possible to use mongoDB aggregate in moleculer, You just have to use MongoDB Adapter in mixins of the service as given in samples given in link to moleculer-db-adapter-mongo. Then in any action of that service you can access any methods like aggregate, find, count, etc as this.adapter.collection.aggregate([your aggregate query]).