Kevin Preston
Posts: 0
Joined: Wed Oct 09, 2013 12:18 pm

Using 'where' in database update

I am trying to use an Appery database, I have no problem creating a record (adding a row) or reading from the database but can't work out how to update. I have a local storage variable with a GUID and I want to update the record that has that GUID. So in SQL it would be something like
"UPDATE users SET person_name = 'smith' WHERE person_GUID = 'xxxxx' "
I have looked at the tutorials etc and cannot figure out how to do this.

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

Using 'where' in database update

Hello! Using Query request to DB you need to retrieve all objects which are satisfy "where" clause. After that run Update service (while each service call specify in URL _id of object)

Kevin Preston
Posts: 0
Joined: Wed Oct 09, 2013 12:18 pm

Using 'where' in database update

Thanks Maryna but could you give an example - how do I get the query variable (GUID) into the _query_service and then get the _id into the _update_service.
Also how do you use queries like

WHERE id = '123' AND status = 'paid'
WHERE status = 'paid' OR status = 'free'

It seems a bit inefficient to have to return the whole row and then send it back again just to change the value in one column or have I misunderstood?

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

Using 'where' in database update

Hi Kevin,

Appery.io uses MongoDB that is not an SQL Database, so you should use another queries: http://docs.appery.io/documentation/b...

Here is how to update data: http://docs.appery.io/documentation/b...

Kevin Preston
Posts: 0
Joined: Wed Oct 09, 2013 12:18 pm

Using 'where' in database update

Thank you for the reply but it doesn't really help much. I have already looked at the linked documentation but have not been able to make sense of it. There are repeated references to 'curl' but as far as I can see no mention of where the curl goes/how it is used. I have no experience of curl (I thought it was a command line tool) and I am sure that I am not alone in wishing the documentation showed clear beginners examples of how to do things. This would save the developers and yourselves a lot of wasted time. I think it will probably be quicker for me to write my own web services to access a SQL server hosted initially by ourselves and then by Amazon/Google/Azure.

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

Using 'where' in database update

Hello!
1) [quote:]I think it will probably be quicker for me to write my own web services to access a SQL server hosted initially by ourselves and then by Amazon/Google/Azure[/quote] Appery.io back-end is based on noSQL DB (MongoDB). You can work with SQL DB if it's easier for you.

2) To run update request with where parameter for Appery.io DB collection:

  • create 2 requests for collection - query and update.
  • run query request with where parameter
  • on query service success event add JS where you check entire response (in data variable) and invoke update service for each _id with needed _id as a request parameter https://getsatisfaction.com/apperyio/...

Return to “Issues”