kfiross / flutter_mongodb_realm

Unofficial Flutter plugin for using MongoDB Realm services on Android, iOS and web.
Apache License 2.0
41 stars 17 forks source link

Not able to updateOne successfully #18

Closed nalnir closed 3 years ago

nalnir commented 4 years ago
collection.updateOne(filter: {'_id': _playId}, update: UpdateOperator.set({"white": _white, "black": _black, "moves": gametostr,"show": val})).then((val){
          setState((){_white=''; _black=''; game=[];});
          showDialog(
            context: context,
            builder: (_)=>AlertDialog(
              title: Center(
                child: Text('Successfully saved to DB and uploaded to Website!'),
              ),
            )
          );
        }).catchError((e){
          print(e);
          );
        });

This function passes and the documents supposedly updates, but the changes are not reflected at all. I think it's because of my filter where I'm using the hexString from ObjectId and so it doesn't find the document at all. I tried to convert id string to ObjectId but then I wasn't able to update at all as I would get the encodable error.

kfiross commented 3 years ago

Hi, Sorry for the long delay, I have added support in v1.2.2 which supposed to fix this issue also.

nalnir commented 3 years ago

No probs, thanks a lot for the addition. I did find the way around just creating additional id field with string type so it's all good for now.