Support Topics Documentation Slack YouTube Blog

Creating Objects Within Each Column

Hi!

I have a data resource. The columns within are properties of the users i.e username, birthdate, etc.

I have a column called comments.

It’s used to collect comments left on the User’s page.

Now on the frontend (Appgyver), I’ve created an object with properties to be stored under the user’s received comments (Backendless).

The objects include each comment with its time generated.
On the frontend, it looks like this: WITH_ITEM(data.userUpdates1.comments, {comment: pageVars.comment_input.text, time: NOW(), id: GENERATE_UUID()})

However, I think there’s an issue, I reckon it’s bcos of the incongruent schema between Backendless and Appgyver. on backendless side it’s either a strong/text, it doesn’t have an option to be an object (which is what will be stored from Appgyver).

By any chance, do you know a way around it? So that what the frontend has received can be stored in backendless as such: object: {comment: ‘abc…’, time: datetime, id: 24387ry343}, {comment:‘cba…’, date: datetime, id:2324343vfv}…

Or something along this line. I’m not sure if this is the best way to store each comment left by others on User A’s page, but this is my current thought process. Thanks!

But it might also have nth to do w backendless but everything is on the front end in matching the properties. Will check it out!

I believe in short, the question is, how to store lists for the columns in backendless?

Data is seen to be captured at the front end, but when it is sent to backendless, even a populated property (column) of a user becomes empty.

thank you so much in advance! :smiley:

Hello @Troy_Lee

You can save objects in a table like a JSON data type, but that not the best solution for your problem I think.
Would be better if you create a new table with comments, and create 1:N relation from the user to her comments.

If something still unclear, please let me know, and we continue to solve your question.

Regards,Dima

Hi Dima,

Thank you for your reply, I appreciate it. :smiley:

I have tried saving on JSON data type but nothing appears in the space too. Saving as a text is super easy.

Just to understand what you mean. For each user, I should set up an individual table so that other users’ comments can be stored there as a property (i.e. time, comment)?

But does that mean for each comment, a new column will have to be created? Bcos it wouldn’t make sense if the user has thousands of comments… :cry:

I ran into the same problem earlier when I was saving the user interests onto backendless, because the interests are also saved as a list, and I haven’t solved that. :crying_cat_face:

Saving them as a text is easy, no problem. But due to the functions available on Appgyver (adding new/removing items to list), i can’t add or remove text directly, it always has to be added/removed from a list.

Hi Troy,

I cannot comment about how things are done in AppGyver, it is not my cup of tea, however, from the data modeling perspective in the backend, I’d use the following structure:


Specifically, it is a one-to-many relationship between the Users and the Comment table. A single user can have multiple comments. To retrieve all comments for a user object, you’d use the following API:
Two Steps Retrieval - Backendless REST API Documentation

Regards,
Mark

Hi Mark, thanks for your reply.

This makes sense. I have turn the comments data type into a data object relationship to an app table called comments (which include comment, created, id).

However, on Appgyver’s GET SCHEMA side to set the schema, it can no longer detect the column ‘comments’. By any chance you know what’s going on?

Hi Troy,

That would be a question for the AppGyver folks. I am not familiar with their system.

Regards,
Mark

Yeap got it, they take ages to reply compared to you. I reckon I’ll be better off figuring it out myself :laughing:

Mark, for the tail of the URL in POST

If I have properties like comment, time created, id as the properties of the new app table, will the tail end of the URL be like this?

REST-API-KEY/data/users/{id}/comments-timecreated-id

Is this the right way to concat the tail end of the URL?

Doesn’t look right. Have you checked in our REST API docs? What operation is this request for?

Thanks Mark. Will do so.

I jumped into another similar problem. Just another qtn Mark, I have saved some list data on Backendless as a JSON type. Is there a way to generate a new column just to convert them as string/text?

Let’s say [“tennis, frisbee, climbing”] → tennis, frisbee, climbing

Hi Troy,

You could use the generated column feature in Backendless.
Here’s an example:


The result will be a string, but it will be formatted the same way as the original JSON

Regards,
Mark

Hi Mark, Thank you so much!!!