Hi Maryna,
It really seems like that should work, but for some reason it doesn't seem to be. I even did a test delete for a fixed record number which worked. Any ideas why it doesn't want to loop through the result object to get the list of _id values (see code below)? Is there a way that I can view what values are being assigned? I'm used to outputting them with a print command, but that doesn't seem to work here.
Can you explain a bit more how to implement console.log? Although I've come a far way with Appery I'm still pretty clueless on many of the basics.
Thanks Maryna!
PS ?How do I do the block greyed out text like yours above? code /code looks unseemly.
code
db_id = '52a4...';
collectionName = 'contacts';
//record_id = '52ec...';
owner_id = '52df...';
var user_id = request.get("user_id"); //Store the user_id
try {
result = {};
var params = {}; //Define parameters object
params.criteria = { //Query criteria:
'r_owner': owner_id
};
result.query = Collection.query(db_id, collectionName, params); //Make the query and save it to the result object
response.success(result);
//Loop through result
//get _id and set as record_id for each row in result.
//Perform delete record based on record_id
var i, len, record_id;
for(i = 0, len = result.length; i < len; i++) {
record_id = result['_id'];
Code: Select all
Collection.deleteObject(db_id, collectionName, record_id);
}
//This TESTdeletion did work so I know it's functional
//record_id = '52dfdb..';
//Collection.deleteObject(db_id, collectionName, record_id);
} catch (e) {
response.success("message: " + e.message + "ncode: " + e.code);
}
/code