Im trying to make a forum using backendless for Android , but I’m stack with two tables , Table Category, and table Question-User, in each category there are many questions of users , so what I want to do is to get all the coments of users per Category, I’m trying with the code provided in backendless API, but I can’t reach my purpose… I’d appreciate if some of you can help me please…
I forget to say that I tried with this code :
BackendlessDataQuery query=new BackendlessDataQuery();value and id_cat are String
query.setWhereClause(“question=’”+value+"’ and id_category=’"+id_cat+"’");…but “question” and “id_category” belong to different tables , because of that it didn’t work
Hi, Jonathan Mamani Herrera .
Have you made relations between your tables ?
For example:
Category (one-to-many) Question
Question (one-to-one) User
Then you could use query with relations.
Try to investigate our documentation: https://backendless.com/documentation/data/android/data_relations.htm
to load object with relation (with ability to update related objects), try this
BackendlessDataQuery query = new BackendlessDataQuery( );
QueryOptions options = new QueryOptions();
options.setRelationsDepth( 1 );
query.setQueryOptions( options );
Backendless.Data.of( YourClass.class ).find(query, ….);
Dear Oleg Vyalyh, I’ve already made relations between tables according to backendless documentation for android, I will try with the information you provided.
Thanks a lot
Hi Oleg Vyalyh, I tried the code you provided but I couldn’t solve my problem… I have two tables :
Category and Question_per_Users , These tables are Classes in my project ,both tables are related (one to many) … but how can I get a list of all questions per Category… please help me
public class Category
{
private Date updated;
private String ownerId;
private Date created;
private String objectId;
private String name_category;
private String id_category;
private List<Question_per_category> question_per_category;
//getters and setters…
public class Question_per_category
{
private Date created;
private Date updated;
private String ownerId;
private String id_pregxcome;
private String objectId;
private String question;