Page 1 of 1

Database - Creating multiple records from List or Array.

Posted: Tue Dec 10, 2013 6:53 pm
by Ricardo Roque

Hi,

I have easily created a List of items from a Collection using a REST operation and mapping. So far so good, it was a very efficient operation since I've got 100 records using just one REST call. But now I have added new information to that list and want to create the same 100 records in another collection. Do I have to call a Create_service for each list item? Can I reuse that List just created to populate another collection using just one Ajax call? Is it possible to use Mapping? Many thanks!


Database - Creating multiple records from List or Array.

Posted: Tue Dec 10, 2013 7:54 pm
by Maryna Brodina

Hello! Sorry. not sure I understand... You want to create in program 100 records based on 100 records you receive in another service from another collection? If just copy collection (and modify it afterwards) you have to export collection and import it back to DB http://docs.appery.io/documentation/b.... If you want to do it in program you have to invoke create service 100 times.


Database - Creating multiple records from List or Array.

Posted: Tue Dec 10, 2013 8:36 pm
by Ricardo Roque

Hi, I don't want to use Import/Export tool but javascript instead. However , Import/Export accepts an array just the way I need inside my app, so I don't know why I can't use the following format to call servicename.execute({}):

The following code doesn't work inside an app. But it should!

pre
o_ = {
data:[
{"reid":{"collName":"goeREForm", "id":"52a"}, "rtid":{"collName":"goeREItem", "id":"529"}, "reApproved":1},
{"reid":{"collName":"goeREForm", "id":"52a"}, "rtid":{"collName":"goeREItem", "id":"530"}, "reApproved":0}
]
};

mycreateservice.execute(o_);
/pre

Cheers.


Database - Creating multiple records from List or Array.

Posted: Tue Dec 10, 2013 9:13 pm
by Maryna Brodina

No, it shouldn't. There is another API for back-end console. You don't have access to that API.


Database - Creating multiple records from List or Array.

Posted: Wed Dec 11, 2013 10:21 am
by Ricardo Roque

Is there a solution using ServerCode? Because 100 calls is very much error prone, so best to execute on server side, if it is possible.

Also, I could use a big object and store it inside a String field but I don't know the limit. Could you tell me?

Thanks


Database - Creating multiple records from List or Array.

Posted: Wed Dec 11, 2013 10:21 am
by Ricardo Roque

:(


Database - Creating multiple records from List or Array.

Posted: Wed Dec 11, 2013 8:21 pm
by Maryna Brodina

Hello! [quote:]execute on server side, if it is possible[/quote] yes, it's possible. Please take a look here http://docs.appery.io/documentation/b...[quote:]big object and store it inside a String field[/quote]should be enough, it's mongodb limit http://docs.mongodb.org/manual/refere...


Database - Creating multiple records from List or Array.

Posted: Wed Dec 11, 2013 10:22 pm
by Ricardo Roque

Sure. Server Code, that is the way! With few lines I solved the problem. Thanks!