You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In [Getting Started](<../001-gettingStarted.md>) we created a `'aparts'` resource which has a field `'realtor_id'`.
22
+
This field refers to record from `'adminuser'` resource. To remind you, we configured this relation using `foreignResource` setting in the column configuration:
23
+
24
+
```typescript title="./resources/apartments.ts"
25
+
//
26
+
exportdefault {
27
+
resourceId: 'aparts',
28
+
...
29
+
columns: [
30
+
...
31
+
{
32
+
name: 'realtor_id',
33
+
foreignResource: {
34
+
resourceId: 'adminuser', // this means that aparts.realtor_id refers to primary key of 'adminuser' resource
35
+
// this is Many-To-One relatin: many aparts can refer to one user
36
+
}
37
+
}
38
+
],
39
+
}
40
+
```
41
+
42
+
This means that we can display a show of user in the apartments show view.
43
+
44
+
Add to your `'apartments'` resource configuration the plugin instance:
45
+
46
+
```ts title="./resources/apartments.ts"
47
+
{
48
+
...
49
+
resourceId: 'aparts',
50
+
...
51
+
//diff-add
52
+
plugins: [
53
+
//diff-add
54
+
newForeignInlineShowPlugin({
55
+
//diff-add
56
+
foreignResourceId: 'users',
57
+
//diff-add
58
+
}),
59
+
//diff-add
60
+
],
61
+
}
62
+
```
63
+
64
+

65
+
66
+
> 👆 To make plugin work, the specified resource (defined with `foreignResourceId`) should have one (and only one) column that refers to the current resource on which you add a plugin.
67
+
> In our case we add plugin to `adminuser` resource, so the `aparts` resource should have one column with `foreignResource.resourceId` equal to `adminuser` resourceId.
0 commit comments