Filter nested documents with collectionlink -> _id fields,

i found solution posting here for someone needs
My goal was getting all posts with related tags included in this request (prevent from makng second request)
so 1st collection is

post

2nd collection

tags

3rd collection is

post-tags-relation

with snippets below i’m getting post entries and getting related tags for each post and adding them to the post entry.to filter relation collection i need to filter “_id” which is located

{
  "post": {
    "_id": "6135b668386234474e000304",  <--- here
    "link": "posts",
    "display": "aaaa"
  },
  "tag": {
    "_id": "61352dda346364830300027e",
    "link": "tags",
    "display": "IZMIR"
  },
  "_by": null,
  "_modified": 1631010110,
  "_created": 1630912806,
  "_id": "6135c126633863531c0001a6",
  "test": "1",
  "_mby": "5fb17db2316366342100001f"
}

and to filter those records

if (COCKPIT_API_REQUEST) {
    $app->on('collections.find.after.posts', function ($name, &$entries) use ($app) {
        foreach ($entries as &$entry) {
            $id = $entry["_id"];
            $tags = $this->module('collections')->find('post-tags-relation', ["filter"=>['tag._id' => $id]]);
            if (!empty($tags)) {
                foreach ($tags as &$tag) {
                    $entry["linked"][]=$tag["tag"];
                }
            } else {
                $entry["linked"][]="";
            }
        }
    });
}

I hope this helps someone needed who like i, desperately digging forum and google…