Quantcast
Viewing all articles
Browse latest Browse all 8068

How to make ACS calls atomic?

Hello,

I am currently using the Appcelerator Cloud as backend and I am running into the problem where I need to add new elements to two tables at the same time. For example, I want to create a custom object called cars and a corresponding photo collection of the cars :

Cloud.Objects.create({ classname: 'cars', fields: { make: 'nissan', color: 'blue', year: 2005 } }, function (e) { if (e.success) { var car = e.cars[0]; Cloud.PhotoCollections.create({ name: 'Car Pictures' owner_id: car.id }, function (e) { if (e.success) { var collection = e.collections[0]; alert('Success:\n' + 'id: ' + collection.id + '\n' + 'name: ' + collection.name + '\n' + 'count: ' + collection.counts.total_photos + '\n' 'updated_at: ' + collection.updated_at); } else { alert('Error:\n' + ((e.error && e.message) || JSON.stringify(e))); } });

} else {
    alert('Error:\n' +
        ((e.error && e.message) || JSON.stringify(e)));
}

});

However, this would not work atomically, ie there maybe cases where the cars is created but not the set of photos. Can someone help me?

Thanks, Wentao Ji


Viewing all articles
Browse latest Browse all 8068

Trending Articles