Skip to content

Commit 0021e0e

Browse files
committed
doc: misc improvements
Fixes #513
1 parent f3172f4 commit 0021e0e

File tree

5 files changed

+141
-6
lines changed

5 files changed

+141
-6
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import CodeBlock from '@theme/CodeBlock';
2+
import TabItem from '@theme/TabItem';
3+
import Tabs from '@theme/Tabs';
4+
5+
interface Props {
6+
package: string;
7+
script: string;
8+
args: string;
9+
}
10+
11+
const pkgManagers = [
12+
{ name: 'npm', command: 'npx' },
13+
{ name: 'pnpm', command: 'pnpm --package=%package dlx', addScript: true },
14+
{ name: 'bun', command: 'bunx' },
15+
{ name: 'yarn', command: 'npx' },
16+
];
17+
18+
const PackageDlx = ({ package: pkg, script, args }: Props) => {
19+
return (
20+
<Tabs>
21+
{pkgManagers.map((pm) => (
22+
<TabItem key={pm.name} value={pm.name} label={pm.name}>
23+
<CodeBlock language="bash">{`${pm.command.replace('%package', pkg)}${
24+
pm.command.includes('%package') ? '' : ` ${pkg}`
25+
}${pm.addScript ? ` ${script}` : ''}${args ? ` ${args}` : ''}`}</CodeBlock>
26+
</TabItem>
27+
))}
28+
</Tabs>
29+
);
30+
};
31+
32+
export default PackageDlx;

versioned_docs/version-3.x/orm/query-builder.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
sidebar_position: 5
3-
description: Query builder API
3+
description: Query Builder API
44
---
55

66
import ZenStackVsPrisma from '../_components/ZenStackVsPrisma';

versioned_docs/version-3.x/orm/quick-start.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ description: Quick start guide
55

66
import StackBlitzGithub from '@site/src/components/StackBlitzGithub';
77
import ZModelStarter from '../_components/_zmodel-starter.md';
8-
import PackageInstall from '../_components/PackageInstall.tsx';
9-
import PackageExec from '../_components/PackageExec.tsx';
8+
import PackageInstall from '../_components/PackageInstall';
9+
import PackageExec from '../_components/PackageExec';
10+
import PackageDlx from '../_components/PackageDlx';
1011

1112
# Quick Start
1213

@@ -30,7 +31,7 @@ Or simply use the [interactive playground](https://stackblitz.com/~/github.com/z
3031

3132
To add ZenStack to an existing project, run the CLI `init` command to install dependencies and create a sample schema:
3233

33-
<PackageExec command="@zenstackhq/cli@next init" />
34+
<PackageDlx package="@zenstackhq/cli@next" script="zen" args="init" />
3435

3536
Then create a `zenstack/schema.zmodel` file in the root of your project. You can use the following sample schema to get started:
3637

versioned_docs/version-3.x/reference/api.md

Lines changed: 103 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ sidebar_label: API
88

99
## `@zenstackhq/orm`
1010

11-
### `class ZenStackClient`
11+
### `ClientContract<Schema>`
12+
13+
The interface for the ZenStack ORM client, implemented by [ZenStackClient](#zenstackclient).
14+
15+
### `ZenStackClient<Schema>`
16+
17+
The class that implements the ORM client.
1218

1319
```ts
1420
/**
@@ -45,4 +51,99 @@ export type ClientOptions<Schema extends SchemaDef> = {
4551
*/
4652
computedFields: ComputedFieldsOptions<Schema>;
4753
};
48-
```
54+
```
55+
56+
#### Query APIs
57+
58+
Please refer to the [ORM Query API documentation](../orm/api/) for more details about query APIs like `findMany`, `create`, `update`, etc.
59+
60+
#### `$connect()`
61+
62+
```ts
63+
/**
64+
* Eagerly connects to the database.
65+
*/
66+
$connect(): Promise<void>;
67+
```
68+
69+
#### `$disconnect()`
70+
71+
```ts
72+
/**
73+
* Explicitly disconnects from the database.
74+
*/
75+
$disconnect(): Promise<void>;
76+
```
77+
78+
#### `$setAuth()`
79+
80+
```ts
81+
/**
82+
* Sets the current user identity.
83+
*/
84+
$setAuth(auth: AuthType<Schema> | undefined): ClientContract<Schema>;
85+
```
86+
87+
#### `$auth`
88+
89+
```ts
90+
/**
91+
* The current user identity.
92+
*/
93+
get $auth(): AuthType<Schema> | undefined;
94+
```
95+
96+
#### `$use()`
97+
98+
Read more in the [Plugins documentation](../orm/plugins/).
99+
100+
```ts
101+
/**
102+
* Returns a new client with the specified plugin installed.
103+
*/
104+
$use(plugin: RuntimePlugin<Schema>): ClientContract<Schema>;
105+
```
106+
107+
#### `$unuse()`
108+
109+
Read more in the [Plugins documentation](../orm/plugins/).
110+
111+
```ts
112+
/**
113+
* Returns a new client with the specified plugin removed.
114+
*/
115+
$unuse(pluginId: string): ClientContract<Schema>;
116+
```
117+
118+
#### `$unuseAll()`
119+
120+
Read more in the [Plugins documentation](../orm/plugins/).
121+
122+
```ts
123+
/**
124+
* Returns a new client with all plugins removed.
125+
*/
126+
$unuseAll(): ClientContract<Schema>;
127+
```
128+
129+
#### `$qb`
130+
131+
Read more in the [Query Builder API documentation](../orm/query-builder).
132+
133+
```ts
134+
/**
135+
* The underlying Kysely query builder instance.
136+
*/
137+
readonly $qb: ToKysely<Schema>;
138+
```
139+
140+
#### `$qbRaw`
141+
142+
Read more in the [Query Builder API documentation](../orm/query-builder).
143+
144+
```ts
145+
/**
146+
* The underlying raw Kysely query builder without any ZenStack enhancements.
147+
*/
148+
readonly $qbRaw: AnyKysely;
149+
```

versioned_docs/version-3.x/reference/cli.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Commands:
2626
info [path] Get information of installed ZenStack packages.
2727
init [path] Initialize an existing project for ZenStack.
2828
check [options] Check a ZModel schema for syntax or semantic errors.
29+
format [options] Format a ZModel schema file.
2930
help [command] display help for command
3031
```
3132

0 commit comments

Comments
 (0)