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 userCollectionName to Mongo object in @accounts/mongo or fix precedence in @accounts/database-mongo-password #1237

Open
orenteriab opened this issue Sep 12, 2022 · 0 comments

Comments

@orenteriab
Copy link

orenteriab commented Sep 12, 2022

The property userCollectionName is not part of the Mongo options in the package @accounts/mongo.

I'm using:

 "@accounts/mongo": "^0.34.0",
 "@accounts/password": "^0.32.0",

I even get the error on TS end, that userCollectionName is not part of Mongo object:
Screen Shot 2022-09-12 at 12 38 19

Screen Shot 2022-09-12 at 12 39 00

Although, the above code runs perfectly, I get that error from TS.

I think, in case you don't want to expose userCollectionName in Mongo object of @accounts/mongo, the precedence for it should be:
1.- userCollectionName in options param.
2.- collectionName in options param.
3.- userCollectionName in defaultOptions.

Here's the current code:

this.options = {
...defaultOptions,
...options,
timestamps: { ...defaultOptions.timestamps, ...options.timestamps },
};

My suggestions would be something like:

constructor(options: MongoServicePasswordOptions) {
    this.options = {
      ...defaultOptions,
      userCollectionName: options.userCollectionName ||
        options.collectionName || defaultOptions.userCollectionName,
      ...options,
      timestamps: { ...defaultOptions.timestamps, ...options.timestamps },
    };

Thanks in advance.

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

No branches or pull requests

1 participant