How to query entities from the Users table in node.js?

I have tried the following code, but I receive the error “Error: Table ‘Users’ is not accessible through this signature. Use Backendless.Data.of( BackendlessUser.class ) instead”. This doesn’t make any sense because this is javascript, there is no BackendlessUser.class, this fails to run at all if I change it. How do I make normal queries (and updates to custom properties) from the Users table using node.js?

var userStorage = Backendless.Data.of( "Users" );
module.exports = {
 getUserByEmail: function(email){
 var dataQuery = new Backendless.DataQuery();
 dataQuery.condition = "email = '" + email + "'";
 return new Promise(function(resolve, reject){
 userStorage.find(dataQuery).then(function(data){
 if (data.data.length > 0){
 resolve(data.data[0]);
 }
 else{
 resolve(null);
 }
 }, reject);
 });
 },

Hi Brandon,

Please, try this

var userStorage = Backendless.Data.of( Backendless.User)

instead of this

var userStorage = Backendless.Data.of( "Users" );

Regards, Ilya

This worked… Thank you. You should really add this to your documentation and fix the error message that is displayed… I lost so many hours trying to figure this out.

Yup, another case of
“One of Things you definitely will need, but won’t be able to find in documentation! But you can search on support forum, Yay!”

Hi Yuriy,

The documentation mentions the className, and there is already a class in JS SDK - Backendless.User.

But we shall consider adding a change to the doc, thanks.