zenstackhq / zenstack-docs

ZenStack documentation
https://zenstack.dev
MIT License
9 stars 19 forks source link

incompatible operand typeszmodel #359

Open jasonmacdonald opened 1 month ago

jasonmacdonald commented 1 month ago

VScode throws an inline error here.

https://github.com/zenstackhq/zenstack-docs/blob/b37c4f7a8a8954d953c45812e62ef1ae5f7413cf/docs/the-complete-guide/part2/3-writing-plugins.md?plain=1#L55

The solution is to define the @@auth attribute on the User

datasource db {
    provider = 'sqlite'
    url = 'file:.dev.db'
}

model User {
    id    Int    @id @default(autoincrement())
    posts Post[]
    @@auth
}

model Post {
    id       Int    @id @default(autoincrement())
    title    String
    author   User   @relation(fields: [authorId], references: [id])
    authorId Int

    @@allow('all', auth() == author)
}

I will hold off submitting a PR since this is only an issue in the VScode plugin, but it could throw off any users trying to follow the docs.