Skip to content

Commit 07209d7

Browse files
committed
updates
1 parent f847870 commit 07209d7

File tree

11 files changed

+26
-26
lines changed

11 files changed

+26
-26
lines changed

versioned_docs/version-3.x/_components/_zmodel-starter.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
```zmodel
22
datasource db {
33
provider = 'sqlite'
4-
url = "file:./dev.db"
4+
url = 'file:./dev.db'
55
}
66
77
model User {

versioned_docs/version-3.x/migrate-prisma.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ ZenStack has its own CLI plugin system and doesn't support Prisma custom generat
159159
}
160160
```
161161
162-
2. Run a`prisma generate` command after `zen generate` with the prisma schema as input.
162+
2. Run a `prisma generate` command after `zen generate` with the prisma schema as input.
163163
164164
```json
165165
{
@@ -175,7 +175,7 @@ ZenStack has its own [runtime plugin mechanism](./orm/plugins/) and doesn't plan
175175

176176
**1. Query extension**
177177

178-
[Query extension](https://www.prisma.io/docs/orm/prisma-client/client-extensions/query) allows you to intercepts ORM query calls.
178+
[Query extension](https://www.prisma.io/docs/orm/prisma-client/client-extensions/query) allows you to intercept ORM query calls.
179179

180180
Suppose you have an extension like:
181181

@@ -258,4 +258,4 @@ export const db = new ZenStackClient(schema, {
258258
});
259259
```
260260

261-
The biggest difference is ZenStack's computed fields are evaluated on the database side, which much more efficient and flexible than client-side computation. Read more in the [Computed Fields](./orm/computed-fields.md) documentation.
261+
A key difference is that ZenStack's computed fields are evaluated on the database side, which much more efficient and flexible than client-side computation. Read more in the [Computed Fields](./orm/computed-fields.md) documentation.

versioned_docs/version-3.x/modeling/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ model Post {
3939
content String
4040
published Boolean @default(false)
4141
author User @relation(fields: [authorId], references: [id])
42-
authorId String
42+
authorId Int
4343
}
4444
```
4545

versioned_docs/version-3.x/modeling/model.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ model User {
2121
}
2222
```
2323

24-
The simplest models are just a collection of fields. A model must be uniquely identifiable by some of its fields. For most cases, you'll have a field marked with the `@id` attribute (more about [attributes](./attribute) later).
24+
The simplest models are just a collection of fields. A model must be uniquely identifiable by some of its fields. In most cases, you'll have a field marked with the `@id` attribute (more about [attributes](./attribute) later).
2525

2626
```zmodel
2727
model User {
@@ -115,7 +115,7 @@ Each model field must at least have a name and a type. A field can be typed in o
115115
```
116116
4. Custom type
117117
118-
ZenStack allows you to define custom types in the schema and use them to type JSON fields. This will be covered in more detail in the [Custom Type](./custom-type) section.
118+
ZenStack allows you to define custom types in the schema and use them to type JSON fields. This is covered in more detail in the [Custom Type](./custom-type) section.
119119
120120
```zmodel
121121
type Address {
@@ -144,7 +144,7 @@ model User {
144144
}
145145
```
146146

147-
A default value can be specified for a field with the `@default` attribute. The value can be a literal, or a supported function call, including:
147+
A default value can be specified for a field with the `@default` attribute. The value can be a literal, an enum value, or a supported function call, including:
148148

149149
- `now()`: returns the current timestamp
150150
- `cuid()`: returns a CUID
@@ -156,8 +156,8 @@ A default value can be specified for a field with the `@default` attribute. The
156156

157157
```zmodel
158158
model User {
159-
id Int @id @default(autoincrement())
160-
role Role @default("USER")
159+
id Int @id @default(autoincrement())
160+
role Role @default(USER)
161161
createdAt DateTime @default(now())
162162
}
163163
```

versioned_docs/version-3.x/modeling/polymorphism.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ It may be tempting to use mixins to share the common fields, however it's not an
2525
- There's no efficient and clean way to query all content types together (e.g., all content owned by a user).
2626
- Consequently, whenever you add a new content type, you'll need to modify the `User` model, and probably lots of query code too.
2727

28-
A true solution involves having a in-database model of polymorphism, where we really have a `Content` table that serves as an intermediary between `User` and the concrete content types. This is what ZModel polymorphism is about.
28+
A true solution involves having an in-database model of polymorphism, where we really have a `Content` table that serves as an intermediary between `User` and the concrete content types. This is what ZModel polymorphism is about.
2929

3030
:::info
3131
There are [two main ways](https://www.prisma.io/docs/orm/prisma-schema/data-model/table-inheritance) to model polymorphism in relational databases: single-table inheritance (STI) and multi-table inheritance (MTI, aka. "Delegate Types"). ZModel only supports MTI.
@@ -99,12 +99,12 @@ erDiagram
9999
Video ||--|| Content: delegates
100100
```
101101

102-
There are two special things about polymorphic base model:
102+
There are two special things about a polymorphic base model:
103103

104104
1. It must have a "discriminator" field that stores the concrete model type that it should "delegate" to. In the example above, the `type` field serves this purpose. It can be named anything you like, but must be of `String` or enum type.
105105
2. It must have a `@@delegate` attribute. The attribute serves two purposes: it indicates that the model is a base model, and it designates the discriminator field with its parameter.
106106

107-
You can also have a deep hierarchy involving multiple level of base models. Just need to make sure each base model has its own discriminator field and `@@delegate` attribute. Extending from multiple base models directly is not supported.
107+
You can also have a deep hierarchy involving multiple levels of base models. Just need to make sure each base model has its own discriminator field and `@@delegate` attribute. Extending from multiple base models directly is not supported.
108108

109109
## Migration behavior
110110

versioned_docs/version-3.x/modeling/relation.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Relations in ZModel
55

66
# Relation
77

8-
Relation is a fundamental concept in relational databases. It lets you connect models into a graph, and allows you to query interconnected data efficiently. In ZModel, relations are modeled using the `@relation` attribute. For most cases, it involves one side of the relation defining a foreign key field that references the primary key of the other side. By convention, we call the model that holds the foreign key the "owner" side.
8+
Relations are a fundamental concept in relational databases. They connect models into a graph and allow you to query interconnected data efficiently. In ZModel, relations are modeled using the `@relation` attribute. In most cases, it involves one side of the relation defining a foreign key field that references the primary key of the other side. By convention, we call the model that holds the foreign key the "owner" side.
99

1010
## One-to-one relation
1111

@@ -272,13 +272,13 @@ enum ReferentialAction {
272272

273273
```zmodel
274274
model User {
275-
id String @id
275+
id String @id
276276
profile Profile?
277277
}
278278
279279
model Profile {
280-
id String @id
281-
user @relation(fields: [userId], references: [id], onUpdate: Cascade, onDelete: Cascade)
280+
id String @id
281+
user User @relation(fields: [userId], references: [id], onUpdate: Cascade, onDelete: Cascade)
282282
userId String @unique
283283
}
284284
```

versioned_docs/version-3.x/orm/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ ZenStack ORM comes with a powerful built-in access control system. You can defin
4848
```zmodel
4949
model Post {
5050
id Int @id
51-
title String @length(1, 256)
51+
title String
5252
published Boolean @default(false)
5353
author User @relation(fields: [authorId], references: [id])
5454
authorId Int
@@ -71,7 +71,7 @@ Real-world applications often involves storing polymorphic data which is notorio
7171
```zmodel
7272
model Content {
7373
id Int @id
74-
name String @length(1, 256)
74+
name String
7575
type String
7676
7777
// the ORM uses the `type` field to determine to which concrete model

versioned_docs/version-3.x/reference/zmodel/datasource.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ datasource NAME {
1717

1818
- **NAME**:
1919

20-
Name of the data source. Needs to be a valid identifier matching regular expression `[A-Za-z][a-za-z0-9_]\*`. Name is only informational and serves no other purposes.
20+
Name of the data source. Must be a valid identifier. Name is only informational and serves no other purposes.
2121

2222
- **`provider`**:
2323

versioned_docs/version-3.x/reference/zmodel/model.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ sidebar_position: 2
44

55
# Model
66

7-
Models represent the business entities of your application. A model can have zero or more [mixins](../../modeling/mixin.md), and zero or more [polymorphic base models](../../modeling/polymorphism.md).
7+
Models represent the business entities of your application. A model can have zero or more [mixins](../../modeling/mixin.md), and zero or one [polymorphic base models](../../modeling/polymorphism.md).
88

99
## Syntax
1010

@@ -16,7 +16,7 @@ model NAME (with MIXIN_NAME(,MIXIN_NAME)*)? (extends BASE_NAME)? {
1616
```
1717
- **NAME**:
1818

19-
Name of the model. Needs to be unique in the entire schema. Needs to be a valid identifier matching regular expression `[A-Za-z][a-za-z0-9_]\*`.
19+
Name of the model. Needs to be unique in the entire schema. Must be a valid identifier.
2020

2121
- **FIELD**:
2222

@@ -36,9 +36,9 @@ model NAME (with MIXIN_NAME(,MIXIN_NAME)*)? (extends BASE_NAME)? {
3636

3737
## Note
3838

39-
A model must be uniquely identifiable by one or several of its fields. For most cases, you'll have a field marked with the `@id` attribute. If needed, you can use multiple fields as unique identifier by using the `@@id` model-level attribute.
39+
A model must be uniquely identifiable by one or several of its fields. In most cases, you'll have a field marked with the `@id` attribute. If needed, you can use multiple fields as unique identifier by using the `@@id` model-level attribute.
4040

41-
If no `@id` or `@@id` is specified, field(s) marked with the `@unique` or `@@unique` attribute will be used as fallback identifier.
41+
If no `@id` or `@@id` is specified, the field(s) marked with the `@unique` or `@@unique` attribute will be used as fallback identifier.
4242

4343
## Example
4444

versioned_docs/version-3.x/reference/zmodel/plugin.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ plugin PLUGIN_NAME {
1717

1818
- **PLUGIN_NAME**
1919

20-
Name of the plugin. Needs to be unique in the entire model. Needs to be a valid identifier matching regular expression `[A-Za-z][a-za-z0-9_]\*`.
20+
Name of the plugin. Needs to be unique in the entire model. Must be a valid identifier.
2121

2222
- **`provider`**
2323

0 commit comments

Comments
 (0)