Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Backendless.ServerCode.enablePromises()
- Backendless.ServerCode.Persistence.beforeCreate('venues_table', function(req) {
- //after calling enablePromises, all asynchronous operations now return a Promise which
- //is very convenient in our case, because we may return it to the CodeRunner
- return Backendless.Counters.of( "venue_counter" ).incrementAndGet().then(
- counter => {
- console.log( "[ASYNC] counter value is - " + counter );
- req.item.venue_id = counter
- },
- error => {
- console.log( "error - " + error.message );
- //throwing the error will interrupt venues-table record creation
- //throw e
- }
- );
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement