Johnny
Posts: 0
Joined: Tue Jul 23, 2013 10:09 am

Update and store

Image

I want to do the following.
If the fields are empty store the fields. If it is not empty update them. All this from one button

How my app works:
User login - show list of categories(each category is a collection in the database) - user fill in data and store the data - user comeback and want to update the data by pressing on the same button as the store button.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Update and store

Hi Johnny,

It depends on your Database structure. Is there one, several or no records for each user in each collection?

Johnny
Posts: 0
Joined: Tue Jul 23, 2013 10:09 am

Update and store

No a row belong to a user. So each user have his own row.

Johnny
Posts: 0
Joined: Tue Jul 23, 2013 10:09 am

Update and store

Sorry i dont what i was reading when awnsering :) every user use every collection. And 1 row in every collection. A user start with no data.

Johnny
Posts: 0
Joined: Tue Jul 23, 2013 10:09 am

Update and store

So first time user create his row in a collection and after that he must just update the info.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Update and store

Johnny,

You would need to create three services:

  1. Reads data from collection and saves result true/false, depending on whether there is a record for the user or not.

  2. Saves data from input fields to Database.

  3. Updates the data.

    On Button click add the action - Invoke Service 1, then read the variable and run Service 2 or Service 3 depending on a variable value.

Johnny
Posts: 0
Joined: Tue Jul 23, 2013 10:09 am

Update and store

Ok I think I have it. Thank you!

Johnny
Posts: 0
Joined: Tue Jul 23, 2013 10:09 am

Update and store

Katya,

Just want to know something about the update.
I create a local variable "objectid" I then open "list_service" and in the response tab I connect the "_id" to that "objectid" variable.

Am I connecting the wrong id? My project is still shared.

Igor
Posts: 0
Joined: Tue Apr 02, 2013 12:05 pm

Update and store

Hi,

If you want update the records you should use update service. Could you clarify what exactly do you want to do?

Johnny
Posts: 0
Joined: Tue Jul 23, 2013 10:09 am

Update and store

Sorry for the late reply.

Ok so my app can Store and List the data. Now I do the update and I thought I did it correctly but there is 1 problem.

I do not know how to explain this but I try.

After I added the update service and link the fields I noticed that when I login with different users the same data display. It was working perfectly before I added the update service.

Return to “Issues”