Skip to content

How can we use findAndModify #8588

Discussion options

You must be logged in to vote

let repo: any = Instance of repo;
const result: any = await new Promise((resolve, reject) => {
repo.dataSource.connector.execute(
'Counter', // collection name
'findAndModify', // command to execute
// additional arguments

      {
        _id: id,
      },
      [['_id', 'asc']],
      {
        $inc: {
          seq: 1,
        },
      },
      {
        new: true,
        upsert: true,
      },

      (err: any, data: any) => {
        if (err) {
          reject(err);
          throw {
            code: 400,
            message: 'Error While Generating Counter',
            name: 'Error While Generating Counter',
          };
        } else {
          resolve(data);
        }
      }…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by paramanandbalara
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant