Hi,
I want to increment field ‘venue_id’ using atomic counter
this is my code
Backendless.ServerCode.Persistence.beforeCreate('venues_table', function(req) {
//add your code here
var successCallback = function( response )
{
console.log( "[ASYNC] counter value is - " + response );
req.item.venue_id = response;
};
var failureCallback = function( fault )
{
console.log( "error - " + fault.message );
};
var callback = new Backendless.Async( successCallback, failureCallback );
// ************************************************
// Backendless.Counters.of() approach
// ************************************************
var myCounter = Backendless.Counters.of( "venue_counter" );
// async call
myCounter.incrementAndGet( callback );
});
when I am invoking beforeCreate, on successful increment callback I am assigning the value on #line6 of the counter to the field name, however nothing happens. Kindly help