read MongoDB create criteria input

BautastenBautasten Member Posts: 7 Contributor I
edited January 2020 in Help
Hi,

I have data that is pulled form a different data source and now I need to use the id from that data in MongoDB criteria to filter the result, I can't figure out how to do that.

Any ideas?

BR,
Patrik

Answers

  • kaymankayman Member Posts: 662 Unicorn
    edited January 2020
    Hi @Bautasten,  One possible solution is the following : 

    - Get the attribute you need (the ID of your source table)
    - If the attribute is a nominal quote it using the replace functions so myID1 becomes "myID1". If it is numeric you can skip this step. 
    - Next use the aggregate operator and concatenate your field, now you get something like "myid1"|"myid2"|"myid3" and so on
    - Replace the pipe (|) with a comma so you get  "myid1","myid2", "myid3"
    - store your field as a macro and call it for instance ids

    Finally call Mongo like {_id:{$in:[%{ids}]} but with using the fields you need
Sign In or Register to comment.