Page 1 of 1

How do I use the query function in the Databases page?

Posted: Sun Jul 06, 2014 3:13 am
by Peter Viglietta

Hi everyone,

As you can probably tell I'm very new to the mobile app development world.. can someone tell me how to use the Query function when you're in the databases section of Appery? I have a bunch of data cleanup that I have to do and I want to be able to run a query to find the problematic rows. How do I run a query equivalent to this SQL query?

SELECT * from Cities where cityname like '%brooklyn%'

In other words, I want to run a query that returns all the cities in my Cities collection whose names contain 'brooklyn'.

Any help is very much appreciated


How do I use the query function in the Databases page?

Posted: Sun Jul 06, 2014 3:57 am
by Illya Stepanov

Hi Peter,

This section in our docs would help: http://devcenter.appery.io/documentat...

And I recommend you to walk through our tutorials here: http://devcenter.appery.io/tutorials/...
-- it will help you better understand DB in Appery.io.


How do I use the query function in the Databases page?

Posted: Mon Jul 07, 2014 12:37 am
by Peter Viglietta

I just need to know how to run a query in Databases my DB Rest query.. what is that field? can I just put a JS query in there? I need to see every record in my Cities table where the City column contains 'Brooklyn'. How do I write that? I'm new to this as you can probably tell


How do I use the query function in the Databases page?

Posted: Mon Jul 07, 2014 8:06 pm
by Evgene Karachevtsev

Hello Peter,

You should pass a json object in the query. SQL function like is implemented through regular expression
You may find more info here:
http://devcenter.appery.io/documentat...
http://docs.mongodb.org/manual/refere...

In your case query would be like this:

code{"cityname" : { $regex: "brooklyn" , $options: "i" }}/code

Image


How do I use the query function in the Databases page?

Posted: Tue Jul 08, 2014 12:55 am
by Peter Viglietta

Thanks Evgene. As you can see I'm still learning the fundamentals, pointers like this are very useful!

In my cities collection I have a City column and a state column. There are many duplicates, for example there are 15 or so iterations of Brooklyn, NY. I want to find all the city/state combinations that have duplicates. Can you tell me that query?


How do I use the query function in the Databases page?

Posted: Tue Jul 08, 2014 9:07 pm
by Alena Prykhodko

Hello Peter,

Unfortunately Appery.io Database API doesn't support such requests.

In order to create query like this you need to get all data from collection (you can do it within project with list service http://devcenter.appery.io/documentat... or from Server code) and then sort it as you need with custom JavaScript, you will need to search online for more information.