Page 1 of 1

Creating a DB Query that queries strings and arrays

Posted: Fri Jun 14, 2013 2:41 pm
by Andy Parker

Hi,

I have a database (example record below);

name[string] id[string] follower_name[array] follower_id[array]
Andy 1000 Bert, Sid 2000,3000

Jim 1001 Andy, Sid 1000,3000

I want to create a query that will return the record that has the following:
{"name":"Jim"} AND "id":"1001" AND "follower_name":"Andy" AND "follower_id":"1000"

I tried the above but it pulls back the Jim record whatever id, follower_id or follower_name I give, it only seems to check the "name".

Can you tell me where I'm going wrong please?

regards

Andy.


Creating a DB Query that queries strings and arrays

Posted: Fri Jun 14, 2013 3:12 pm
by Maryna Brodina

Hello! Try this code{"name":"Jim", "id":"1001", "follower_name": "Andy", "follower_id":"1000"}/code


Creating a DB Query that queries strings and arrays

Posted: Fri Jun 14, 2013 3:14 pm
by Andy Parker

great, many thanks!

One last question, how would I use the rest service to delete one of the array entries, eg: one of the follower_ids [like 1000] from the follower_ids array?

the idea being that I want to revoke a follower_id from the follower_id array by using a rest service call.


Creating a DB Query that queries strings and arrays

Posted: Fri Jun 14, 2013 3:37 pm
by Maryna Brodina

This should help http://docs.appery.io/documentation/b...

In follower_id should be something like
code{"__op":"Remove","objects":["1000", "1005"]}/code


Creating a DB Query that queries strings and arrays

Posted: Fri Jun 14, 2013 3:46 pm
by Andy Parker

thanks again.

appreciate your help.