Page 1 of 1

update an array in database

Posted: Sun Jan 21, 2018 1:53 am
by Yahya

Dears,

I want to use mongoDB $push or $addToSet to append to an array in a collection
when I execute the below code I got successful result but no update happen to the array in the collection , please advise.

update_request_login_page.execute({
'data' : {
"$addToSet": {"driversRecivedTheRequest": "999999" }

Code: Select all

                                         }, 

                                         'parameters': { 
                                                 reqID: "5a63c695a428937aa506b06f" 
                                         }, 
                                         success: function(data){ 
                                             toast('تم تعديل حالة الطلب..!!'); 
                                         }, 

                                         error: function(e){ 
                                            toast('خطأ لم يتم تعديل حالت الطلب..!!'); 
                                         } 
                                     });

update an array in database

Posted: Mon Jan 22, 2018 8:58 am
by Serhii Kulibaba

Hello,

Appery.io doesn't support these parameters ($push and $addToSet).

Please look at this example how to add a unique value to the array: https://docs.appery.io/reference#data...


update an array in database

Posted: Mon Jan 22, 2018 1:25 pm
by Yahya

Thank you for the response, in fact I want to add a string to an existing array example:
var name="john";
"deviceRejectedTheRequest":{"__op":"AddUnique","objects":jhon}

the above command failed to add the name to the array object in database.
the array in database like : ["sara","warren","sam"] , how to add "Jhon" to this array.

Thank you.


update an array in database

Posted: Tue Jan 23, 2018 6:19 am
by Yahya

Any update


update an array in database

Posted: Tue Jan 23, 2018 10:13 am
by Serhii Kulibaba

Please send the variable "name" in your request. It seems the variable "jhon" is not defined there.

Could you please clarify what you have tried and what exactly does not work?

Please check if there are any errors in the browser console. You can learn here: https://docs.appery.io/docs/using-bro... how to open the console.