Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions versioned_docs/version-3.x/_components/PackageDlx.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import CodeBlock from '@theme/CodeBlock';
import TabItem from '@theme/TabItem';
import Tabs from '@theme/Tabs';

interface Props {
package: string;
script: string;
args: string;
}

const pkgManagers = [
{ name: 'npm', command: 'npx' },
{ name: 'pnpm', command: 'pnpm --package=%package dlx', addScript: true },

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe the short way es pnpx --package=%package

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why but it doesn't seem to work ...

image

Copy link

@herberthobregon herberthobregon Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You must run pnpx --package=@zenstackhq/cli@next zenstack init, using zenstack not zen

For future readers, you must include --package=@zenstackhq/cli otherwise it will think you need to install zenstacks package (v2).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For incomprehensible reasons, I got the same error with "zen" and "zenstack" ... tried cleaning pnpm dlx cache but doesn't seem to help. It feels like pnpx is not even trying to fetch the package

{ name: 'bun', command: 'bunx' },
{ name: 'yarn', command: 'npx' },
];

const PackageDlx = ({ package: pkg, script, args }: Props) => {
return (
<Tabs>
{pkgManagers.map((pm) => (
<TabItem key={pm.name} value={pm.name} label={pm.name}>
<CodeBlock language="bash">{`${pm.command.replace('%package', pkg)}${
pm.command.includes('%package') ? '' : ` ${pkg}`
}${pm.addScript ? ` ${script}` : ''}${args ? ` ${args}` : ''}`}</CodeBlock>
</TabItem>
))}
</Tabs>
);
};

export default PackageDlx;
2 changes: 1 addition & 1 deletion versioned_docs/version-3.x/orm/query-builder.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
sidebar_position: 5
description: Query builder API
description: Query Builder API
---

import ZenStackVsPrisma from '../_components/ZenStackVsPrisma';
Expand Down
7 changes: 4 additions & 3 deletions versioned_docs/version-3.x/orm/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ description: Quick start guide

import StackBlitzGithub from '@site/src/components/StackBlitzGithub';
import ZModelStarter from '../_components/_zmodel-starter.md';
import PackageInstall from '../_components/PackageInstall.tsx';
import PackageExec from '../_components/PackageExec.tsx';
import PackageInstall from '../_components/PackageInstall';
import PackageExec from '../_components/PackageExec';
import PackageDlx from '../_components/PackageDlx';

# Quick Start

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

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

<PackageExec command="@zenstackhq/cli@next init" />
<PackageDlx package="@zenstackhq/cli@next" script="zen" args="init" />

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

Expand Down
105 changes: 103 additions & 2 deletions versioned_docs/version-3.x/reference/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ sidebar_label: API

## `@zenstackhq/orm`

### `class ZenStackClient`
### `ClientContract<Schema>`

The interface for the ZenStack ORM client, implemented by [ZenStackClient](#zenstackclient).

### `ZenStackClient<Schema>`

The class that implements the ORM client.

```ts
/**
Expand Down Expand Up @@ -45,4 +51,99 @@ export type ClientOptions<Schema extends SchemaDef> = {
*/
computedFields: ComputedFieldsOptions<Schema>;
};
```
```

#### Query APIs

Please refer to the [ORM Query API documentation](../orm/api/) for more details about query APIs like `findMany`, `create`, `update`, etc.

#### `$connect()`

```ts
/**
* Eagerly connects to the database.
*/
$connect(): Promise<void>;
```

#### `$disconnect()`

```ts
/**
* Explicitly disconnects from the database.
*/
$disconnect(): Promise<void>;
```

#### `$setAuth()`

```ts
/**
* Sets the current user identity.
*/
$setAuth(auth: AuthType<Schema> | undefined): ClientContract<Schema>;
```

#### `$auth`

```ts
/**
* The current user identity.
*/
get $auth(): AuthType<Schema> | undefined;
```

#### `$use()`

Read more in the [Plugins documentation](../orm/plugins/).

```ts
/**
* Returns a new client with the specified plugin installed.
*/
$use(plugin: RuntimePlugin<Schema>): ClientContract<Schema>;
```

#### `$unuse()`

Read more in the [Plugins documentation](../orm/plugins/).

```ts
/**
* Returns a new client with the specified plugin removed.
*/
$unuse(pluginId: string): ClientContract<Schema>;
```

#### `$unuseAll()`

Read more in the [Plugins documentation](../orm/plugins/).

```ts
/**
* Returns a new client with all plugins removed.
*/
$unuseAll(): ClientContract<Schema>;
```

#### `$qb`

Read more in the [Query Builder API documentation](../orm/query-builder).

```ts
/**
* The underlying Kysely query builder instance.
*/
readonly $qb: ToKysely<Schema>;
```

#### `$qbRaw`

Read more in the [Query Builder API documentation](../orm/query-builder).

```ts
/**
* The underlying raw Kysely query builder without any ZenStack enhancements.
*/
readonly $qbRaw: AnyKysely;
```
1 change: 1 addition & 0 deletions versioned_docs/version-3.x/reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Commands:
info [path] Get information of installed ZenStack packages.
init [path] Initialize an existing project for ZenStack.
check [options] Check a ZModel schema for syntax or semantic errors.
format [options] Format a ZModel schema file.
help [command] display help for command
```

Expand Down