Page 1 of 1

Database services - changing instances

Posted: Sat May 03, 2014 12:12 am
by Anthony Hyams

I have a query service to a collection in my database that gets events on a particular date. If I create an instance of this on a page it adds the service to the page and I give it a new name. I can then edit mappings etc. All this seems fine

If I now edit the underlying service does this change all instances of the service? So for example if I wanted to get saturdays events for one page and sundays events for another page. Do I need to create two copies of the query service. Or do I create one instance with the where = saturday and then edit the query service so the where = sunday and create a new instance on the required page?


Database services - changing instances

Posted: Sat May 03, 2014 7:30 am
by Igor

Hello,

[quote:]
If I now edit the underlying service does this change all instances of the service?
[/quote]
It change only Datasource on the screen.
http://docs.appery.io/documentation/r...

[quote:]
Do I need to create two copies of the query service
[/quote]
You don't need to create two copies. You just need one query service which you can use in the different screens with different parameters.


Database services - changing instances

Posted: Sat May 03, 2014 10:43 am
by Anthony Hyams

I've read the service documentation and don't have a problem adding a service. However that documentation is very ambiguous when it comes to the role of a service and an instance of the service.

Your answer seems at odds with the interface. When I create an instance and name it there is a link to the service. If I click it it allows me to edit the service. So I can change an existing where parameter. However if I go to a page using an instance of the service - the same link exists - if I click it then it shows the same changed query. Suggesting both instances are using the same underlying service.

I have got round the confusion by duplicating services based on what query I want to run, so if I have a query service for a collection I create a query service for each different requests (this is a lot of services) then add it to the page. I suspect this is not efficient or how you envisaged it being used. However it is very unclear how services and instances of those service relate to each other


Database services - changing instances

Posted: Sun May 04, 2014 6:40 am
by Serhii Kulibaba

Hello Anthony,

Each instance of the service is not dependent.
You should use one service but different whrere parameter. Add mapping localStorage variable - where.
Where you need run service with parametr "saturday" or "sunday", set it to the localStorage variable and run service after