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

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Works as Designed
    • Priority: Major - P3
    • None
    • Affects Version/s: 1.4.1
    • Component/s: None
    • None
    • Environment:
      Ubuntu 20.04
      go version go1.15.3 linux/amd64
    • None
    • None
    • None
    • None
    • None
    • None
    • None

       

      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

            Assignee:
            Unassigned
            Reporter:
            Rubi N/A
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: