How to get items from a database in EVENT HANDLERS and operate on their properties

As I haven’t already tried, it returns null, although everything is in the table.

var contactStorage = Backendless.Data.of( “spher” );
var queryBuilder = Backendless.DataQueryBuilder.create();
queryBuilder.setWhereClause( “name = ‘Programing(test)’” );
var a = contactStorage.find( queryBuilder )
return a[0].hour

Have you tried testing your where clause in backendless console? Here’s an article on how to do it, the screenshots are for the previous version of Backendless and will be a bit different, but the functionality is there: https://backendless.com/how-to-use-sql-based-search-for-data-objects-in-backendless-console/

In addition, contactStorage.find( queryBuilder ) returns an instance of Promise, so you have to use async/await or then method to get a list of “spher” objects

async function YOUR_METHOD_NAME(){ ...

  var a = await contactStorage.find( queryBuilder )

  return a[0].hour
}
function YOUR_METHOD_NAME(){ ...

  return contactStorage.find( queryBuilder ).then(a => {
     return a[0].hour
  }) 
}

Regards, Vlad

1 Like