Page 1 of 1

How to calculate total count of a database query, using list items for the search query?

Posted: Tue Aug 05, 2014 3:42 pm
by Chiran

I have a list item which is populated from a database collection.

I would like to query another collection in the database, with each of the list items as search terms, and then generate the total number of results generated for each list item.

For e.g.

List shown on page (generated from column in collection 1 of database):
Ford
Honda
Toyota
Mercedes

Collection 2 of database contains:
Column 1: Car Type; Column 2: Number plate

Ford: abc123
Ford: hgd973
Mercedes: hdk907
Ford: dsd976
Toyota:

I would like to show in the list on the page, next to each car type, the total number of number plates for each matching car from collection 2 of the database.

So,

Ford - 3
Honda - 0
Toyota - 0 (had a blank entry for number plate)
Mercedes - 1

I am having difficulty with being able to query the items from the list array into the 'where' section of the request component of the query service, and also returning the total count.

Your help is greatly appreciated.


How to calculate total count of a database query, using list items for the search query?

Posted: Tue Aug 05, 2014 5:03 pm
by Evgene Karachevtsev

Hello Chiran,

Please look at this link: http://devcenter.appery.io/documentat...


How to calculate total count of a database query, using list items for the search query?

Posted: Wed Aug 06, 2014 12:58 am
by Chiran

Hi Evgene,

I had a look at the link - I need this to work on a local database (as this app will be used offline), and I'm not sure I can do that with CURL commands?

I'm not sure where I should put the CURL command:
pre
curl -X GET
-H "X-Appery-Database-Id: 526fdbd8e4b07c3286b537f1"
-G --data-urlencode 'count=1'
https://api.appery.io/rest/1/db/collections/todo
/pre

Also, the collection has multiple columns - how will this code know:
-to use the dynamically generated list items as the search input (to request the query)?
-and then which column to search in the database collection?

Thank you.


How to calculate total count of a database query, using list items for the search query?

Posted: Wed Aug 06, 2014 9:16 am
by Maryna Brodina

Hello!

Could ypu clarify what is local DB - SQLite?


How to calculate total count of a database query, using list items for the search query?

Posted: Wed Aug 06, 2014 11:58 am
by Chiran

Yes, using 'localstoragevariable'


How to calculate total count of a database query, using list items for the search query?

Posted: Wed Aug 06, 2014 7:50 pm
by Evgene Karachevtsev

Chiran,

Please look at this link, information there should be useful for you: https://developer.appcelerator.com/qu...