Skip to content

Commit addfdb3

Browse files
authored
currentModel renamed to modelAlias in computed-fields.md (#490)
1 parent ccc7e99 commit addfdb3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

versioned_docs/version-3.x/orm/computed-fields.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const db = new ZenStackClient(schema, {
4747
});
4848
```
4949

50-
The computed field callback is also passed with a second `context` argument containing other useful information related to the current query. For example, you can use the `currentModel` property to refer to the containing model and use it to qualify field names in case of conflicts.
50+
The computed field callback is also passed with a second `context` argument containing other useful information related to the current query. For example, you can use the `modelAlias` property to refer to the containing model and use it to qualify field names in case of conflicts.
5151

5252
```ts
5353
import { sql } from 'kysely';
@@ -56,11 +56,11 @@ const db = new ZenStackClient(schema, {
5656
...
5757
computedFields: {
5858
User: {
59-
postCount: (eb, { currentModel }) =>
59+
postCount: (eb, { modelAlias }) =>
6060
eb.selectFrom('Post')
61-
// the `currentModel` context property gives you a name that you can
61+
// the `modelAlias` context property gives you a name that you can
6262
// use to address the containing model (here `User`) at runtime
63-
.whereRef('Post.authorId', '=', sql.ref(currentModel, 'id'))
63+
.whereRef('Post.authorId', '=', sql.ref(modelAlias, 'id'))
6464
.select(({fn}) => fn.countAll<number>().as('count')),
6565
},
6666
},

0 commit comments

Comments
 (0)