Page 1 of 1

Mapping Pointers to filter query results

Posted: Thu Dec 25, 2014 7:23 pm
by Pablo

Hello

I'm going to ask a question regarding DB Pointers.

I have 2 collections Order and OrderItem

In OrderItem i have a pointer to Order: http://puu.sh/dJ7T1/fb0821584e.png

The secuence goes like this

1) An order is made: http://puu.sh/dJ8b4/94ac01f44e.png
2) Items are added to the database (pointing the order created): http://puu.sh/dJ89G/f5c37fa937.png

My question is how to retrieve all the items from the current Order.
This is my request: http://puu.sh/dJ8mo/dfbaec8704.png
Even when i test it seems to be ok: http://puu.sh/dJ8iJ/26ca654841.png
I'm trying to send the Order ID to the where field : http://puu.sh/dJ8rR/3753731de2.png
But i get this message on the console: http://puu.sh/dJ8w4/f6fb1c21ac.png

I need to know how to make the mapping to get the Order ID to the where statment.

I hope the explanation of the problem it's clear. If not, please ask as many questions you need.

Thanks.


Mapping Pointers to filter query results

Posted: Thu Dec 25, 2014 11:27 pm
by Yurii Orishchuk

Hi Pablo,

To filter all items by pointer value you can use "$inQuery" clause.

See details here: http://devcenter.appery.io/documentat...

So you filter will be:

pre

{order: {"$inQuery": {_id: "123123123123123" } }}

/pre

Regards.


Mapping Pointers to filter query results

Posted: Fri Dec 26, 2014 12:08 am
by Pablo

I've already tryed that. I think my problem is in the request or the mapping.

My request: http://puu.sh/dJqS4/19d2cdea8e.png
The test with that ID is successfull: http://puu.sh/dJqXC/0db38c73f7.png

but i dont know how to send the ID i want dynamically.
This is my mapping: http://puu.sh/dJr5j/70076288bf.png

Can you please clarify how to set the filter.

Thanks


Mapping Pointers to filter query results

Posted: Fri Dec 26, 2014 4:09 am
by Yurii Orishchuk

Pablo,

Ah... ok,

Just follow these steps:

  1. Delete link to "_id" parameter.
    Details: http://prntscr.com/5kzxmf/direct

  2. Delete "_id" request parameter.(from server request tab).

  3. Open mapping and make link from "order" storage to "where" request parameter.

  4. Click on "JS" for that link and populate editor with following code:

    pre

    console.log("value = " + value);

    var whereObject = {order: {"$inQuery": {_id: value } }};

    console.log("whereObject = " + JSON.stringify(whereObject));

    return JSON.stringify(whereObject);

    /pre

    That's all.

    Regards.


Mapping Pointers to filter query results

Posted: Fri Dec 26, 2014 4:32 am
by Pablo

This works like a charm!

Thanks Yurii Orishchuk. I'm doing a tutorial in Spanish with all this tricks.

Thanks again!


Mapping Pointers to filter query results

Posted: Fri Dec 26, 2014 8:39 am
by Alena Prykhodko

Great, good luck :)


Mapping Pointers to filter query results

Posted: Sun Jun 28, 2015 10:16 pm
by Jack Bua

Is there a tutorial that covers this method of filtering and usage of pointers?


Mapping Pointers to filter query results

Posted: Tue Jun 30, 2015 3:22 pm
by Illya Stepanov

Hi Jack -

Unfortunately we do not have such tutorial at the moment, but we will consider to create it in future.