Requesting all data at once

Forum to discuss the new web client version of Servoy.

Requesting all data at once

Postby jay.rao » Fri May 19, 2017 8:23 am

Hello,


I am trying to achieve few things here i.e loading all the database records at once,actually I am trying to perform few operations on client side just for testing so I want to load all the records at once lets say I have 2128 records in db I would want to have all the records with single query of 'Select * ' .So is there any possiblity of loading it using loadExtraRecordsAsync,loadRecordsAsync or anything similar to that?
I am aware of using rawSql to write query and fectch the records but actually I want to perform this things on foundset at clientSide.


Regards,
Jay
jay.rao
 
Posts: 59
Joined: Mon Apr 10, 2017 1:32 pm

Re: Requesting all data at once

Postby jay.rao » Tue May 23, 2017 7:16 am

Is there a way to load all records at once on clientSide?
is it possible to use any combinations in foundset i.e $scope.model.foundset.loadRecordsAsync() to load all the records ? I have created a component and I would like to fetch all the records at once at component_clientSide.js or if possible at component_serverSide.js.
All I want is to load all the records in my client side/server side foundset as we cannot use databaseManager.getFoundSetCount(...) at component_serverSide.js/component_clientSide.js
jay.rao
 
Posts: 59
Joined: Mon Apr 10, 2017 1:32 pm

Re: Requesting all data at once

Postby Andrei Costescu » Tue May 23, 2017 10:05 am

Ideas:
- you can configure "initialPreferredViewPortSize" to a very high number in the .spec file.
- in server side scripting you can access the $scope.model.myfoundset.foundset - and there you can just do getRecord(getSize()) until size is not increasing anymore in order to load the whole foundset server-size. You could call that each time you notice on the client that $scope.model.myfoundset.hasMoreRows becomes true. Then you will know the full size and you can adjust the viewport to send everything to client via loadExtraRecordsAsync or loadRecordsAsync.

Are you sure you want to do that though? Send 2128 records at once from server to browser?
I also created SVY-11169 for extending api access for server-side scripting. If you have API that would really be needed in server-side scripting of components and services you can comment on that case.
Andrei Costescu
Servoy
Andrei Costescu
 
Posts: 1018
Joined: Tue Jun 26, 2007 3:14 pm

Re: Requesting all data at once

Postby roym » Tue May 23, 2017 2:01 pm

if your table is not likely to change (add/delete) records, you can preload your foundset from a dataset that contains all the primary keys.

example:

var b = datasources.db.pcd.item.createSelect()
b.result.add(b.columns.item_id)

var z = datasources.db.pcd.item.getFoundSet()
z.loadRecords(databaseManager.getDataSetByQuery(b, -1))

application.output(z.getSize())
roym
 
Posts: 1
Joined: Mon Nov 12, 2012 9:32 pm

Re: Requesting all data at once

Postby jay.rao » Tue May 23, 2017 3:54 pm

Hello roym,Andrei


Thank you for the solutions,actually what I tried is configured "initialPreferredViewPortSize" to very high number and then simply fetched the serverSize after first db call using $scope.model.foundset.serverSize and with serverSize count I called $scope.model.foundset.loadExtraRecordsAsync($scope.model.foundset.serverSize) to get all the data.


I tried the solution of getRecords at component_server.js but couldn't achieve it so I tried my above code at component_client.js.
Also I am not sure why $scope.model.myFoundset.foundset.loadExtraRecordsAsync() didn't work,I tried $scope.model.myFoundset.foundset.loadExtraRecordsAsync(100) but failed to return anything as it didnot call itself at component_server.js.

I am awaiting for pivoting and grouping from Servoy.
jay.rao
 
Posts: 59
Joined: Mon Apr 10, 2017 1:32 pm


Return to Servoy NGClient

Who is online

Users browsing this forum: No registered users and 7 guests

cron