Array of Objects

Thread is closed for posting
3 posts, 0 answers
  1. Christopher
    Christopher avatar
    2 posts
    Member since:
    Oct 2014

    Posted 15 Aug 2017 Link to this post

    In the backend console, there seems to be no way to add an array of objects using the interface. You can add an array of text, numbers, etc. but not an empty array or an array of objects. We want to designate some fields as being an array ready to accept objects.

    We are not storing relations in the array - we need to store multiple row values for a record in one-to-many grids like this:

    Content Type: Properties
    hasMoved: true;  //this is a regular field storing one-to-one value 
    APN: [{Seq: 500, value: ‘Hello’}, {Seq: 600, value: ‘Goodbye’}]  //this is a grid field storing more than one grid value entry for this record

    We just want to create a field for APN that is an array that will ultimately hold objects.

    What are we doing wrong?

    Thanks.

  2. Anton Dobrev
    Admin
    Anton Dobrev avatar
    609 posts

    Posted 16 Aug 2017 Link to this post

    Hi,

    In the Structure of your Properties content type you can define the APN field as an Object and you will get the option to use a complex object creator and visualizer for this field in the create/detail view of an entity. 

    Please note that doing so will have an UI-only effect, in the database you will be able to store any supported type and value to this field. Put simply, you only need to send the value of the field in the payload to the server and it will be written to the database, independent of the type you declared in the Structure. You can read more about this here

    For some fields like GeoPoint you still need to define them in the structure though. Same for setting a field value constraint as unique. 

    I hope this answers your question. 
       
    Regards,
    Anton Dobrev
    Progress Telerik
     
    Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
     
  3. Christopher
    Christopher avatar
    2 posts
    Member since:
    Oct 2014

    Posted 16 Aug 2017 in reply to Anton Dobrev Link to this post

    Thanks Anton. I understand.

    Also, in this case, we created a separate content type for each grid to store the value for each grid row set of items. This looks like it is better suited for that function.

    Thanks again.

Back to Top