1 If you get the following error in your Medusa application's terminal:
2
3 ```bash
4 Trying to query by not existing property LinkModel.X.
5 ```
6
7 Where `X` is the name of a data model. For example, `LinkModel.cart`.
8
9 ## Why this Error Occurred
10
11 This error occurs when you're using Query and you're trying to filter by a linked module, which isn't allowed.
12
13 For example, assuming you have a `Post` data model and you linked it to the `Cart` data model, this isn't allowed:
14
15 ```ts
16 const { data } = await query.graph({
17 entity: "post",
18 fields: ["*"],
19 filter: {
20 cart: {
21 id: "cart_123",
22 },
23 },
24 })
25 ```
26
27 You can't filter your custom `post` data model by the ID of their linked cart.
28
29 ---
30
31 ## How to Fix it
32
33 You need to query the link's table directly and apply the filters on its ID columns. For example:
34
35 ```ts
36 import PostCartLink from "../links/post-cart"
37
38 // ...
39
40 const { data } = await query.graph({
41 entity: PostCartLink.entryPoint,
42 fields: ["post.*", "cart.*"],
43 filters: {
44 cart_id: "cart_123",
45 },
46 })
47 ```
48
49 In the above example, you query the `PostCartLink` data model directly and apply the filters to the `cart_id` field, which holds the ID of the cart linked to the post. You'll then only retrieve the posts linked to the cart with the ID `cart_123`.
50
51 ---
52
53 ## Additional Resources
54
55 - [Query](!docs!/learn/fundamentals/query#apply-filters-and-pagination-on-linked-records)