KEG
Posts: 0
Joined: Thu Feb 13, 2014 6:54 pm

Subdocument query testing howto

I have this example scenario:

DB collections:
———————————————————
cardealer:
id, name
———————————————————
cars:
id, pointer to cardealer, name
———————————————————
parts:
id, pointer to cars, name
———————————————————

Testing the parts_query_service

Included automatically by service:
carID, carID.cardealerID

Query service result with a blank query:
(only one result pasted in here)

-------------------------------------------------------------------

[
{
"createdAt":"2014-02-14 20:52:15.320",
"id":"52fe81ffe4b0e3176f3e7468",
"updatedAt":"2014-02-16 14:44:25.986",
"name”:”Parts name,
“carID”:{
"createdAt":"2014-02-13 20:26:28.587",
"id":"52fd2a74e4b0e3176f3e3069",
"updatedAt":"2014-02-13 20:27:05.071",
"name”:”Cars name”,
“cardealerID:{
"id":"52fbec8ee4b0e3176f3e2d00",
"name”:”Cardealer name”,
"createdAt":"2014-02-12 21:50:06.585",
"_updatedAt":"2014-02-12 21:50:06.585"
}
}
}
]

--------------------------------------------------------------------

How do I get all the parts from one cardealer having the cardealerID?
What do I put in the "where" field for testing this service query to achieve this?

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Subdocument query testing howto

Hello,

Please take a look here http://docs.appery.io/documentation/b...

KEG
Posts: 0
Joined: Thu Feb 13, 2014 6:54 pm

Subdocument query testing howto

Hi!

Thank you, but I've read that 10 times. If you would show me how to query this example, I might get some sleep!

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Subdocument query testing howto

Hi,

Add a request parameter 'subtask' and pass a value to it:
pre{"collName":"cardealerID", "_id":"52fa49cce4b0a25c11c85b87"}/pre
Where 52fa49cce4b0a25c11c85b87 is the cardealer ID.

KEG
Posts: 0
Joined: Thu Feb 13, 2014 6:54 pm

Subdocument query testing howto

Hi!

I've come to the conclusion that I've tried that before. My query responds with success, but no records.

I must be doing something wrong somewhere. Now I'm REALLY lost.

No problem finding parts if I use the carID:
{"carID._id":"52fd2a74e4b0e3176f3e3069"}

KEG
Posts: 0
Joined: Thu Feb 13, 2014 6:54 pm

Subdocument query testing howto

If one of you like to, you could access a test project I've set up and maybe explain this.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Subdocument query testing howto

Hi,

Please post a screenshot of service test tab.

KEG
Posts: 0
Joined: Thu Feb 13, 2014 6:54 pm

Subdocument query testing howto

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Subdocument query testing howto

Hi,

1) I see nothing in your 'where' parameter.

2) This is incorrect:pre{"carID.id":"52fd2a74e4b0e3176f3e3069"}/prePlease use this code as we advised:pre{"collName":"carID", "id":"52fd2a74e4b0e3176f3e3069"}/pre

KEG
Posts: 0
Joined: Thu Feb 13, 2014 6:54 pm

Subdocument query testing howto

Hi!

Yes it's blank in that screenshot to show the structure of the response.

Take a look at my new screenshots. The query suggested does not return anything.

The carID._id example I suggested, is just a working example of how I get all parts with the car id (all parts related to that one car)
{"carID.id":"car-_id-goes-here"}.
Which works as you can se in my screenshot.

I'm trying to get all the parts using the cardealer _id somehow.
Or a explanation how to do this in some way or another.

There was also suggested this format from you in this forum:
{"collName":"cardealerID", "id":"cardealer-id-goes-here"}

Which is not working either. (Screenshot)

Image Image Image

Return to “Issues”