Home > Blockchain >  MongoError: Found unexpected fields after $each in $addToSet
MongoError: Found unexpected fields after $each in $addToSet

Time:12-25

MongoError: Found unexpected fields after $each in $addToSet

      await Profile.updateOne(
        { ref },
        {
          $addToSet: {
            "contact": {
              $each: [ "addr" ],
              $position: 0,
            },
          },
        }
      );

CodePudding user response:

$position is a modifier for $push only, and cannot be used with $addToSet.

  • Related