Mongoose finds but does not update the document

Asked

Viewed 22 times

0

I am using Mongoose in my code and can’t update documents, but with mongodb it works normally, whenever I try to update a document, it returns the following results and does not update the document:

{
  n: 1,
  nModified: 0,
  ok: 1
}

My update code:

1 ° The function I created in my repository:

async update(id: string, entity: object, options: QueryOptions = { upsert: true }): Promise<Query<any, any>> {
   return this.model.updateOne({ _id: id }, entity, options);
}

2° What I call her:

await this.client.database.users?.update(user.id, {
  $inc: {
     xp: wonXP
  }
});

I’ve tried to use $set in the update query but results in the same

  • Tried to use findOneAndUpdate in place of updateOne?

  • Yes, there in my role I am using "updateOne", but I adapted to a repository that I am doing to call in my client

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.