Zero 0.7
Read Permissions and Docker
Install
npm install @rocicorp/zero@0.7
Features
- Read permissions. You can now control read access to data using ZQL (docs).
- Deployment. We now have a single-node Docker container (docs). Future work will add multinode support.
- Compound FKs. Zero already supported compound primary keys, but now it also supports compound foreign keys (docs).
- Schema DX:
Breaking Changes
- Several changes to
schema.ts
. See update tohello-zero
for overview. Details:defineAuthorization
was renamed todefinedPermissions
to avoid confusion with authentication.- The way that many:many relationships are defined has changed to be more general and easy to remember. See example.
- The signature of
definePermissions
and the related rule functions have changed:- Now rules return an expression instead of full query. This was required to make read permissions work and we did it for write permissions for consitency (see example).
- The
update
policy now has two child policies:preMutation
andpostMutation
. The rules we used to have werepreMutation
. They run before a change and can be used to validate a user has permission to change a row. ThepostMutation
rules run after and can be used to limit the changes a user is allowed to make.
- The
schema.ts
file should export an object having two fields:schema
andpermissions
.
- The way that
schema.ts
is consumed has also changed. Rather thanzero-cache
directly reading the typescript source, we compile it to JSON and read that. (example).ZERO_SCHEMA_FILE
should now point to a JSON file, not.ts
. It defaults to./zero-schema.json
which we’ve found to be pretty useful so you’ll probably just remove this key from your.env
entirely.- Use
npx zero-build-schema
to generate the JSON. You must currently do this manually each time you change the schema, we will automate it soon.
🤔Note
zbugs
- Comments now have permalinks. Implementing permalinks in an SPA with local-first is fun!
- Private issues. Zbugs now supports private (to team only) issues. I wonder what’s in them … 👀.
Docs
- The docs have moved. Please don’t use Notion anymore, they won’t be updated.