Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add id alias for json object to override default _id #182

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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

@@ -25,7 +25,7 @@ class 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