loopback-connector-mongodb

This is an extension to loopback-connector-mongodb ( https://github.com/strongloop/loopback-connector-mongodb)v4.0.0

This project is changed from original project for

  • To query Mongo database to perform Groupby and aggregation operations. This is very specific to Oe-cloud.

Note: Test cases may not work.

Please refer loopback documentation at Github.

Programmatic id generation

The connector can allow developers to provide their own id generation logic during new record creation. To enable this we need to do the following:

  1. Use the customized datasources config file (e.g. server/datasouces.local.js)
  2. set enableConnectorIdGeneration to true
  3. set idGenerateFn to the following a function which takes model name as first argument, and, the data (or payload) as the second argument. The function should return a id value or undefined. If the latter, the value of the property will default to whatever is defined in the database/table/field. The context of this function will be the connector instance itself.

Troubleshooting

For troubleshooting, it may be required to see the queries issued by the connector. Two things are required. (a) add debug to true in the datasource connector properties in the main application, and, (b) set the DEBUG environment variable (e.g. export DEBUG=loopback:connector:mongodb). A general recommendation here would be set the debug property based on reading the environment variable via nodejs (process.env.DEBUG). This way we only need to set the environment variable prior to startup.