Advanced Data Retrieval

Suppose I have a “Questions” table and “Users” table, and a third table “HiddenQuestions”, where I insert pairs (user, question), meaning the user has “totally understood” this question and no longer wishes it to appear during his sessions (I’m writing an exam preparation app). Now, what sort of whereClause should I write so that only not-hidden questions are retrieved for the logged in user? Of course, I could first retrieve hidden questions for the user AND all questions separately and handle the removal of the hidden questions in the code, but with two AsyncCalls we cannot guarantee that one list will be available when processing the other…

Before we respond, I need to make this post “public”. Just wanted to make sure, you’re ok with it.

Mark

Yes Mark, please.

Since there is no support for JOINS in our SQL, you need to know the list of objectId values for the hiddenQuestions. It could be stored either as you already do it with a 3rd table or perhaps as a JSON array (as a string) in a user property. Once you have that collection, the following whereClause would do it when you query objects from Questions:

objectId not in ('objectId1', 'objectId2', 'objectId3'.. etc )

Regards,
Mark

Hi Kazi

please I don’t know if my comment answers your question but for me I would have set a Boolean flag for all questions to a default value say hiddenQuestion=“false” then the user can update the question by setting it to hiddenQuestion=“true”. I think that will make the whereClause much easier to use on the questions table.

Regards,

Ps. Jimmy

Hi Jimmy,

your suggestion would work fine if there were only one user. For multiple users – alas.

–S