Ricardo Roque
Posts: 0
Joined: Tue Nov 26, 2013 11:22 am

Database - Creating multiple records from List or Array.

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!

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Database - Creating multiple records from List or Array.

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.

Ricardo Roque
Posts: 0
Joined: Tue Nov 26, 2013 11:22 am

Database - Creating multiple records from List or Array.

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.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Database - Creating multiple records from List or Array.

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

Ricardo Roque
Posts: 0
Joined: Tue Nov 26, 2013 11:22 am

Database - Creating multiple records from List or Array.

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

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Database - Creating multiple records from List or Array.

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...

Ricardo Roque
Posts: 0
Joined: Tue Nov 26, 2013 11:22 am

Database - Creating multiple records from List or Array.

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

Return to “Issues”