cancel
Showing results for 
Search instead for 
Did you mean: 

How are multiple values stored in properties (in sequence or random order)?

sunquanbin
Champ on-the-rise
Champ on-the-rise
Dear all,

I'm trying to store some pair array data in a custom data type. The custom type represents a group. and within this group, it has many members. The members' names and genders are stored within this custom type. The xml file is like:


      <type name="demo:group">
         <parent>cm:content</parent>
         <properties>
            <property name="demo:GroupName">
               <type>d:text</type>
            </property>
            <property name="demo:MemberNames">
               <type>d:text</type>
               <multiple>true</multiple>
            </property>
            <property name="demo:MemberGenders">
               <type>d:text</type>
               <multiple>true</multiple>
            </property>
         </properties>
      </type>



Let's say I have three members: {A, B, C} and theirs genders are {Male, Male, Fefale}. When I using a JS controller to create/update a Node of this type, I used array to pass in these two properties (i.e. MemberNames and MemberGenders.

My question is: will those arrays be saved in the same order as I passed in (and remain the same order when I retrieve them)? As if the item order was randomly, there will be a mis-match between Name and Gender.

Many thanks,

Sun
3 REPLIES 3

srivastava123
Champ in-the-making
Champ in-the-making
Hi Sun,

I have created a custom model and it uses a muli-select list for input of the values. In this case, I have observed that the items are always stored in the sequence in which they are selected i.e. from top of the list towards the bottom.
In your case also, it should be in the same order, so there should not be any variation in the relation between the two columns.

Hope it helps you Smiley Happy

Many thanks for the test.

In my test and observation, those appeared in sequence as well. The only reason I raise this question was to understand how is such sequence structure storaged in Alfresco. I.E. is this sequence order guaranteed or it just happened in those occasions that you and I tested? Otherwise, it cannot be relied on. 

jpotts
World-Class Innovator
World-Class Innovator
Yes, you can rely on multi-valued properties returning in a consistent order. Associations, on the other hand, are not always returned in the same order.

Jeff