Pablo
Posts: 0
Joined: Thu Dec 25, 2014 4:29 pm

Mapping Pointers to filter query results

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.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Mapping Pointers to filter query results

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.

Pablo
Posts: 0
Joined: Thu Dec 25, 2014 4:29 pm

Mapping Pointers to filter query results

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

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Mapping Pointers to filter query results

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.

Pablo
Posts: 0
Joined: Thu Dec 25, 2014 4:29 pm

Mapping Pointers to filter query results

This works like a charm!

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

Thanks again!

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

Mapping Pointers to filter query results

Great, good luck :)

Jack Bua
Posts: 0
Joined: Sun Jun 28, 2015 10:16 pm

Mapping Pointers to filter query results

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

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Mapping Pointers to filter query results

Hi Jack -

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

Return to “Issues”