Page 1 of 1

questions about query with pointer fields

Posted: Mon Nov 04, 2013 6:19 pm
by Helsen

Hi Appery.io team
I have 3 collections

company
field: _id
field: _name

category
field: _id
field: _name

company_category
field: _id
field: id_company (pointer field to company)
field: id_category (pointer field to category)

I have a query Service to COMPANY_CATEGORY that show all data in COMPANY and CATEGORY collections.

But I need data from specific category (where category._name = 'food').

I don ́t know what I need write in JAVASCRIPT of WHERE in this service. Please help me


questions about query with pointer fields

Posted: Mon Nov 04, 2013 7:02 pm
by Kateryna Grynko

Hi Helsen,

You should add request parameter "where" and pass there something like thispre{"id_category": {"$in": arr}}/preWhere 'arr' is a variable containing an array of categories id. This array can be obtained from another service, which will get the data from the collection 'category'. Here parameter 'where' is added with the value pre {"_name":"food"}/pre


questions about query with pointer fields

Posted: Mon Nov 04, 2013 7:45 pm
by Helsen

Thanks for reply Katya,

I know how to use the query with where and "$in", sorry for my bad english.

My problem is how to use query with where, when use values obtained from pointers fields.


questions about query with pointer fields

Posted: Mon Nov 04, 2013 8:45 pm
by Helsen

To be more specific, can you explain your doc (Queries on Pointer Values):

http://docs.appery.io/documentation/b...

with my Collection schema?


questions about query with pointer fields

Posted: Tue Nov 05, 2013 12:00 pm
by Helsen

??


questions about query with pointer fields

Posted: Tue Nov 05, 2013 12:14 pm
by Maryna Brodina

Hello! Sorry for delay. We have noSql DB and there are no such requests to collection. For "company_category" collection you can retrieve all records from "category" collection and using JS select what you need. To retrieve all records use "include" in request.


questions about query with pointer fields

Posted: Fri Nov 29, 2013 7:38 pm
by bahar.wadia

This can be very inefficient, especially if the dataset is large. There has to be another away to get the desired dataset more efficiently.

Are you sure there is no other way ?