Releases: zenstackhq/zenstack-v3
ZenStack Release v3.0.0-alpha.6
What's Changed
- Runtime plugins are now compatible with Prisma's client extension
- Fixed incorrect computed field typing #33
- Upgraded to zod4
- Upgraded eslint
- Set up turborepo
- CI for auto-bump-version and auto-release
- Cleaned up a bunch of small dependencies by @DoctorFTB
New Contributors
- @DoctorFTB made their first contribution in #37
- @github-actions made their first contribution in #51
Full Changelog: v3.0.0-alpha.4...v3.0.0-alpha.6
ZenStack Release v3.0.0-alpha.4
What's New
This is the very first alpha release of ZenStack v3 🎉. The release focuses on implementing the ORM part using Kysely, keeping the schema language and query APIs compatible with Prisma.
Please see GitHub homepage for documentation for now.
Implemented features:
-
New
zenstack generatecommand that generates a simple, all-in-one TypeScript schema representationschema.tsfrom ZModel. The file is meant to be compiled/bundled with your source tree. -
The
ZenStackClientclass as a drop-in replacement toPrismaClientimport { schema } from './zenstack/schema'; import SQLite from 'better-sqlite3'; const client = new ZenStackClient(schema, { dialectConfig: { database: new SQLite('./dev.db') } });
-
The entire Prisma-compatible ORM query API surface that you already know:
findUnique,create,count,aggregate, etc.const users = await client.user.findMany({ where: { role: 'ADMIN' }, include: { posts: true } });
-
Query builder API powered by Kysely, fully typed, zero extra configuration
await client.$qb .selectFrom('User') .leftJoin('Post', 'Post.authorId', 'User.id') .select(['User.id', 'User.email', 'Post.title']) .execute();
-
Using query builder in ORM query filters
await client.user.findMany({ where: { age: { gt: 18 }, // "eb" is a Kysely expression builder $expr: (eb) => eb('email', 'like', '%@zenstack.dev'), }, });
-
Database-evaluated computed fields with
@computedZModel declaration:
model User { ... postCount Int @computed }
TS implementation:
const client = new ZenStackClient(schema, { ... computedFields: { User: { postCount: (eb) => eb .selectFrom('Post') .whereRef('Post.authorId', '=', 'User.id') .select(({ fn }) => fn.countAll<number>().as('postCount') ), }, }, });
The field can then be used anywhere a regular field can (read only of course).
-
Runtime plugins for intercepting queries and entity mutations.
See here for more details.
Limitations
- Only sqlite (better-sqlite3) and postgresql (pg) are supported for now.
- Raw SQL query APIs (
$queryRawand$executeRaw) are not supported. Use query builder API instead. - Prisma client extensions are not supported.
Packages
@zenstackhq/cli: replaceszenstackpackage in V2, containing thezenstackCLI.@zenstackhq/runtime: ORM runtime
Full Changelog: https://github.com/zenstackhq/zenstack-v3/commits/v3.0.0-alpha.4