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

DollarPrefixedFieldName - MongoDB error #171

Open
sharife3 opened this issue Feb 12, 2021 · 0 comments
Open

DollarPrefixedFieldName - MongoDB error #171

sharife3 opened this issue Feb 12, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@sharife3
Copy link

When running the project and following the steps i came across an issue with findOneAndUpdate in the base-mongo.repository.ts located in the repo-orm lib.

When executing the code it complained with this error:

[Nest] 44633 - [RegisterUserHandler] Object:
{
"ok": 0,
"code": 52,
"codeName": "DollarPrefixedFieldName",
"name": "MongoError"
}

To get this working, i changed the it from { $set: { ...req.updates } } to { ...req.updates }

from:

 async findOneAndUpdate(req: UpdateRequest): Promise<DOC> {
    const collection = await this.collection;
    const updates = await this.invokeEvents(
      PRE_KEY,
      ['UPDATE', 'UPDATE_ONE'],
      { $set: { ...req.updates } },
    );

to:

 async findOneAndUpdate(req: UpdateRequest): Promise<DOC> {
    const collection = await this.collection;
    const updates = await this.invokeEvents(
      PRE_KEY,
      ['UPDATE', 'UPDATE_ONE'],
      { ...req.updates },
    );

Hope this is helpful

@juicycleff juicycleff added the bug Something isn't working label Feb 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants