How to use '$push' and '$pull' operations ??



  • From the documentation it is not totally clear to me how to construct a correct JSON request for the $push and $pull operation.
    In my case, I have a object with a "contacts" field that it's an array of strings.
    From C++, I created the following JSON (as stated in the documentation of EnginioClient):
    @{
    "$push": {
    "contacts": "5367cdf7698b3c0a5a0333fe"
    },
    "id": "537cfb9c5a3d8b5408026e63",
    "objectType": "objects.datprivate"
    }@
    And Enginio reply with a generic "Internal Server Error".

    What I did wrong ??

    Thanks.


  • cid:52:privileges:purge

    At this moment atomic update operations are not implemented in Enginio Qt library.

    Normally you can make atomic update request by sending PUT request to /objects/objects.datprivate/537cfb9c5a3d8b5408026e63/atomic end point, with the following json payload

    @{
    "$push": {
    "contacts": "5367cdf7698b3c0a5a0333fe"
    }@

    "See REST API reference for more details":https://developer.qtcloudservices.com/eds/rest/v1/put_objects_collection_id_atomic

    Since you can't do this with Enginio Qt library at this moment, you have to include all contacts values in json and make a normal update, for example

    @{
    "id": "537cfb9c5a3d8b5408026e63",
    "objectType": "objects.datprivate",
    "contacts": ["5367cdf7698b3c0a5a0333fe", "5367cdf7698b3c0a5a0333fg"]
    }@


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.