Skip to content

Conversation

derekrliang
Copy link

This allows the returned JSON entity object to have a custom key such as id instead of the default MongoDB id _id.

Example:

const DbMixin = (collection: string) => {
  return {
    mixins: [DbService],
    adapter: new MongoAdapter(
      process.env.MONGO_URI, {
        useNewUrlParser: true,
        useUnifiedTopology: true,
        jsonId: "id",
      }
    ),
    collection,
  };
};

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 93.536% when pulling 7796bfc on derekrliang:feature/add-id-alias-json-obj into c2f9d43 on moleculerjs:master.

@coveralls
Copy link

coveralls commented Apr 23, 2020

Coverage Status

Coverage decreased (-0.2%) to 93.536% when pulling 0f416d3 on derekrliang:feature/add-id-alias-json-obj into c2f9d43 on moleculerjs:master.

@derekrliang derekrliang force-pushed the feature/add-id-alias-json-obj branch from 7796bfc to 0f416d3 Compare April 23, 2020 07:10
Copy link
Member

@icebob icebob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing unit tests

*
* @memberof MongoDbAdapter
*/
constructor(uri, opts, dbName) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could

constructor(uri, opts = { }, dbName)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants