Support Topics Documentation Slack YouTube Blog

Save Object Within Database Table Column

Are you looking for help?

This is a support forum for reporting issues related to Backendless services. Please note that due to our support policy we cannot provide you help with debugging your code, consulting in regards to any language or third-party library usage. For this kind of questions we recommend using more appropriate forums like Stack Overflow.

In order to suggest you a quality solution, we shall usually ask you to provide the details mentioned below first. Including them into your topic right away helps us to start investigating your issue much faster.

In case you have a suggestion or an idea, the details below are not always required, though still any additional background is welcome.

Backendless Version (3.x / 5.x, Online / Managed / Pro )

5.4.1 Online

Client SDK (REST / Android / Objective-C / Swift / JS )

JS

Application ID

1916AD34-DDE0-8B22-FF6E-68F3668F8400

Expected Behavior

Please describe the expected behavior of the issue, starting from the first action.

  1. Save an object with a nested object (not another class): eg. Post { objectId, text, { entities: [{ beginOffset, endOffset, score, text, type }] } }
  2. As you can see, the third column is an object with a property called entities with an array of objects.
  3. The object should save and nest this object within the Post.

Actual Behavior

Please provide a description of what actually happens, working from the same starting point.

Be descriptive: “it doesn’t work” does not describe what the behavior actually is – instead, say “the request returns a 400 error with message XXX”. Copy and paste your logs, and include any URLs.

  1. There is no way to add plain objects to a model, only relations to other tables. It’s extremely tedious in many cases and would be much easier to just add a single object into the model. Is this possible?

Reproducible Test Case

Please provide a simple code that could be run in a new clean app and reproduce the issue.

If the issue is more complex or requires configuration, please provide a link to a project on Github that reproduces the issue.

Hi @Garrett_Gottlieb

If I understood you correctly - you’d like to save an object and to establish relation in one call. If so then this is not possible with Backendless. In order to establish relation you need all objects to be created and then call an API to set relation between them: https://backendless.com/docs/android/data_set_relation_with_objects_android.html

However you can create your own API service in Business Logic tab, which will be establishing relation under the hood. This may be done in order to minimize number of calls on client side: https://backendless.com/docs/bl-java/bl_basic_quick_start_guide.html

Anton

No, I’d like to save an object with a JSON field in it, not a relation.

You can declare a String or Text column and store your json text in it. If the text (json) is too big, save it in a file and then store the URL for the file in the database.