Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-1796

Upsert with $inc: write errors: '$inc' is not valid for storage

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Works as Designed
    • Icon: Major - P3 Major - P3
    • None
    • 1.4.1
    • None
    • None
    • Ubuntu 20.04
      go version go1.15.3 linux/amd64

    Description

       

      opt := options.Update() opt.SetUpsert(true) 
      upd, err := mgdb.Collection("users_usage").UpdateOne(context.TODO(), filter, bson.M{"$set": update}, opt)

      given this code with update data :

      // code placeholder
      update := bson.M{"user_id": userID,"$inc": bson.M{"usage_total": 1}}
      

      resulting in error :

      multiple write errors: [{write errors: [{The dollar ($) prefixed field '$inc' in '$inc' is not valid for storage.}]}, {<nil>}]

      but when i disable the upsert, the error gone

      Attachments

        Activity

          People

            Unassigned Unassigned
            jihantoro8@gmail.com Rubi N/A
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: