mirror of
https://github.com/zenstackhq/zenstack
synced 2026-05-24 10:08:55 +00:00
Co-authored-by: Augustin <43639468+Azzerty23@users.noreply.github.com> Co-authored-by: Jonathan Stevens <jonathan.stevens@resnovas.com> Co-authored-by: Jonathan S <jonathan.stevens@eventiva.co.uk> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: ErikMCM <70036542+ErikMCM@users.noreply.github.com> Co-authored-by: Jason Kleinberg <ustice@gmail.com> Co-authored-by: Jonathan S <punk.gift9475@alias.org.uk> Co-authored-by: Jiasheng <jiashengguo@outlook.com>
33 lines
889 B
TypeScript
33 lines
889 B
TypeScript
import superjson from 'superjson';
|
|
|
|
export const schema = `
|
|
model User {
|
|
id String @id @default(cuid())
|
|
createdAt DateTime @default (now())
|
|
updatedAt DateTime @updatedAt
|
|
email String @unique @email
|
|
posts Post[]
|
|
|
|
@@allow('all', auth() == this)
|
|
@@allow('create,read', true)
|
|
}
|
|
|
|
model Post {
|
|
id String @id @default(cuid())
|
|
createdAt DateTime @default (now())
|
|
updatedAt DateTime @updatedAt
|
|
title String
|
|
author User? @relation(fields: [authorId], references: [id])
|
|
authorId String?
|
|
published Boolean @default(false)
|
|
publishedAt DateTime?
|
|
viewCount Int @default(0)
|
|
|
|
@@allow('all', author == auth())
|
|
@@allow('read', published)
|
|
}
|
|
`;
|
|
|
|
export function makeUrl(path: string, q?: object, useSuperJson = false) {
|
|
return q ? `${path}?q=${encodeURIComponent(useSuperJson ? superjson.stringify(q) : JSON.stringify(q))}` : path;
|
|
}
|