Search code examples
feathersjs

Is there a way we can write mongodb aggregation pipeline by customizing services in feathers js


Can anyone provide basic examples of how to customize a feathers service to perform mongodb aggregation pipeline? I have tried it with hooks but I lost in the midway.


Solution

  • You can create Custom Service in FeathersJs where in the class you can use aggregation or also in hooks you can use it.

    EX : I have service users I want to get data through aggregation.

    const userData = context.app.service('users').Model.aggregate([
        // Use Your pipelines here
    ]);