Page 1 of 1

Save array as multiple rows in collection

Posted: Sun Feb 02, 2014 9:25 pm
by Graeme6630509

i am trying to add two values into a collection. one is a number, the other is an array. I would like a new row for each value in the array

e.g. number: 1 array:[1, 2, 3]
Collection:
col1 col2
1 1
1 2
1 3

Is this possible? If it helps the array values are being taken from a checkbox.


Save array as multiple rows in collection

Posted: Sun Feb 02, 2014 9:46 pm
by Illya Stepanov

Hello -

No, you would need to parse your array and update data in collection programmatically.
:: http://docs.appery.io/documentation/b...
:: http://docs.appery.io/documentation/b...


Save array as multiple rows in collection

Posted: Sun Feb 02, 2014 10:44 pm
by Graeme6630509

So I would need to add the call to the database to javascript? Is there any documentation on this?


Save array as multiple rows in collection

Posted: Mon Feb 03, 2014 12:53 am
by Alena Prykhodko

Graeme,

This post might help https://getsatisfaction.com/apperyio/...


Save array as multiple rows in collection

Posted: Mon Feb 03, 2014 9:37 pm
by Graeme6630509

Thanks,

I used code similar to the following to solve my issue:

var checked = new Array();

code
Appery("mobilecheckboxgroup_12").find(":checked").each(function(){
checked .push($(this).val());
});

for(i=0; i<<code>&#46;length; i++){

Code: Select all

 myService&#46;execute({ 
     data :{ 
             "col_a" : 1, 
             "col_b" : checked , 
     } 

 }); 

}
/code