Chiran
Posts: 0
Joined: Sat Aug 02, 2014 1:59 pm

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

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.

Chiran
Posts: 0
Joined: Sat Aug 02, 2014 1:59 pm

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

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.

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

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

Hello!

Could ypu clarify what is local DB - SQLite?

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

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

Chiran,

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

Return to “Issues”