Giter Club home page Giter Club logo

Comments (2)

umar-anzar avatar umar-anzar commented on June 11, 2024

prisma/schema.prisma

generator client {
  provider             = "prisma-client-py"
  interface            = "asyncio"
  recursive_type_depth = "5"
  partial_type_generator = "prisma/partial_types.py"
}

model User {
  id                  Int           @id @default(autoincrement())
  name                String        @db.VarChar(30)
 age Float
 password String
 country String
}

Run prisma generate

prisma/partial_types.py

from prisma.models import User
User.create_partial('UserWithName', include={'name'})

db.py or any where prisma client is intialize

import prisma
from prisma import Prisma

prisma_client: Prisma = Prisma()
prisma.register(prisma_client)

Run prisma generate

# Use of Partial Type
from prisma.partials import UserWithName

user = await UserWithName.prisma().find_first(
  where={
    'country': 'Scotland',
  },
)
print(user.name)

print(user.id)  # error `id` does not exist on the `UserWithName` type

Partial Types - Prisma Client Python (prisma-client-py.readthedocs.io)

Selecting Fields - Prisma Client Python (prisma-client-py.readthedocs.io)

from prisma-client-py.

afi-dev avatar afi-dev commented on June 11, 2024

I know you have to use the partial type for this, but I suggest making it less abstract by adding the select which only exists on the Prisma JS library, by dint of which I was a bit disgusted not to have the select and preferred to code directly with the prismaJS library.

from prisma-client-py.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.