0

I have this code:

function incrementarValor (sequenceName){
  contador.findOneAndUpdate(
    {_id: sequenceName},
    {$inc:{sequence_value:1}},
    {new:true},
    function(err, valor){
        return valor.sequence_value;
    })}

I need this function returns a value of a document, when I test it ,if i try to print, it works but when i try to returns the function give me a undefind

someone know what is happening?

1 Answers1

0
contador.findOneAndUpdate({ _id: sequenceName }, { $inc:{sequence_value:1} }, function(err, user) {
  if (err) throw err;

  // we have the updated user returned to us
  contador.log(user);

please note that the update method doesn't return the document. The update statement only return an acknowledgement.

satish chennupati
  • 2,602
  • 1
  • 18
  • 27