Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a TypedDict for every model #847

Open
RobertCraigie opened this issue Nov 30, 2023 Discussed in #838 · 0 comments
Open

Provide a TypedDict for every model #847

RobertCraigie opened this issue Nov 30, 2023 Discussed in #838 · 0 comments
Labels
kind/feature A request for a new feature. level/intermediate priority/low topic: types An issue or improvement to typing

Comments

@RobertCraigie
Copy link
Owner

Discussed in #838

Originally posted by NixBiks November 20, 2023
Does there exist a generated TypedDict which represents a table as they look in the database?

I've been looking in prisma.types but no luck.

E.g. for I'd like something like

from typing import Literal, Optional, TypedDict


LogLevel = Literal["NOTSET", "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]

class LogInDB(TypedDict):
    id: int
    level: LogLevel
    message: str
    worker_id: Optional[str]

for a schema like this

enum LogLevel {
  NOTSET
  DEBUG
  INFO
  WARNING
  ERROR
  CRITICAL
}

model Log {
  id        BigInt   @id @default(autoincrement())
  level     LogLevel
  message   String
  worker_id String?
}
@RobertCraigie RobertCraigie added topic: types An issue or improvement to typing kind/feature A request for a new feature. level/intermediate priority/low labels Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature A request for a new feature. level/intermediate priority/low topic: types An issue or improvement to typing
Projects
Status: No status
Development

No branches or pull requests

1 participant