Support Topics Documentation Slack YouTube Blog

How to retrive user table data based on condition in angularjs

Hi,
I have UserId as a column in Users table. I am trying to get user object based on UserId in angularjs.

I tried

var dataQuery = new Backendless.DataQuery();
dataQuery.condition = "UserId = "+userId;
Backendless.Persistence.of( ‘Users’ ).find(dataQuery);

It didn’t work,then tried
Backendless.Data.of( Backendless.User);
I got this output
{“className”:“Users”,“restUrl”:“https://api.backendless.com/v1/data/Users”}
not the user object. Please could anybody help me.

Thank you.

Try adding single quotes on “userId” in where clause:

dataQuery.condition = "UserId = '"+userId + "'";

Not working, got this error

ionic.bundle.js:26794 Error: Table ‘Users’ is not accessible through this signature. Use Backendless.Data.of( BackendlessUser.class ) instead

Have you tried using Backendless.Data.of( BackendlessUser.class ) instead?

Yes,but I got this output
{“className”:“BackendlessUser.class”,“restUrl”:“https://api.backendless.com/v1/data/BackendlessUser.class”}

But I need User object.

I mean, Backendless.Data.of( BackendlessUser.class ).find(dataQuery);

You can’t map your own class to the Users table. And the only way to work with the Users table is using BackendlessUser class.

I tried above query but got 400 status code. and the response was
{“code”:2024,“message”:“Wrong entity name: name must not have a symbol ‘.’”}.

I apologize, for javascript it should be

Backendless.Data.of(Backendless.User).find(dataQuery)

Thank you Sergey Chupov it is working.