Conditional data retrieval for user privacy in a shared database

Hi,

I am setting up a shared database where logged in users will have CRUD capabilities. However, since the users must only have access to their own records for privacy reasons, I want the data load function to only provide records associated with each user’s ownerId property. I can get the filtering to work in the REST console and data browser but the API setup is giving me trouble.

I am trying to use logic blocks of On Mounted, return: and Load Table Objects. The Where Clause property of the Load Table Object block doesn’t let me add both elements of an equality comparison logic block to test the “Get current user” block value against a text block containing “ownerId” property.

What API logic works for filtering records into a Data Table component based on current (logged in) user identity?

Hi Richard,

Could you rephrase the following to describe what you want to do rather an a solution of how you approach it?

Also, if you could share a screenshot of a query setup in “REST console”, we can assist in replicating it in codeless.

Regards,
Mark

Hi Mark,

Thanks for the offer of assistance in developing the codeless logic flow. I want the users of a common/shared database for appointments to access only their appointments. The filtered appointments would flow into a Data Table component on the frontend. Since each ownerId property is uniquely assigned to a user at registration, and ownerId values are assigned to each added appointment, I felt that would be the best property by which to isolate the records of each user.

Here is the REST console view for pulling test data for a particular pseudo-user. This particular example correctly yields just four records. The challenge is also getting the filter criteria to be dynamically based on the current (logged in) user’s identity.

Essentially, I want my backend logic to filter the source dataset (the centralized appointment table) so the user only sees their own records in their browser. The user can then utilize the data manipulation controls in the browser’s Data Table component to further isolate selected appointments as desired.

Hi Richard,

The following Codeless logic will perform the same query as shown in the screenshot you shared:

However, I believe a better approach would be to use a feature built into Backendless called “Owner Policy”. See a how-to article linked below for a walkthrough describing how to set it up:

Regards,
Mark

Hi Mark,

The owner policy and roles permission approach worked, is global for the app, and I agree more efficient to implement; hence, I will be using it. So, thanks for that.

FYI, the new codeless logic scheme prevented any records from coming through to the data table for me. What logic blocks did you use to precede the Load Table Object block since I can’t start the record filtration process with that one?

I did not use have any logic blocks preceding it. The logic I demonstrated replicates the query you showed.