https://www.prisma.io/ logo
Join SlackCommunities
Powered by
# orm-help
  • w

    William GM

    03/14/2022, 7:25 PM
    Hello! Could someone please take a peek at this discussion! https://github.com/prisma/prisma/discussions/12293
    👍 1
  • m

    Mounir Bennacer

    03/14/2022, 8:14 PM
    👋 Hello, team!
  • m

    Mounir Bennacer

    03/14/2022, 8:15 PM
    glad i found your slack channel 🙂
  • m

    Mounir Bennacer

    03/14/2022, 8:16 PM
    i have a question regarding Postgres daterange, i know it's not supported yet but i have a hard time implementing it with
    Copy code
    prisma.$queryRaw
  • m

    Mounir Bennacer

    03/14/2022, 8:17 PM
    as an example this query:
    Copy code
    SELECT *
    FROM IMPACTS
    WHERE COMPANY_ID = 1
    AND '[2020-01-01,2020-12-31]'::daterange @> during
    GROUP BY 1
    ORDER BY 1 ASC
  • m

    Mounir Bennacer

    03/14/2022, 8:18 PM
    this exact query return me this error ( using Express 😞
    Copy code
    {
      "error": {
        "code": "P2010",
        "clientVersion": "3.10.0",
        "meta": {
          "code": "N/A",
          "message": "error deserializing column 2: cannot convert between the Rust type `core::option::Option<alloc::string::String>` and the Postgres type `daterange`"
        }
      }
    }
    n
    • 2
    • 1
  • l

    Lars Ivar Igesund

    03/14/2022, 8:23 PM
    Well, you do have quotes around the date array (not sure that is the string that is referred to though)
    n
    • 2
    • 1
  • a

    ali

    03/15/2022, 12:33 AM
    Hi … I am trying to query based on whether JSON is null, but keep running into
    Type 'string' is not assignable to type 'JsonNullableFilter'.
    This is the query on Postgres. I have added
    filterJson
    as a preview feature and run prisma generate. Is it supposed to be different?
    Copy code
    my_users = await this.prisma.user.findMany({
            where: {
              metadata: Prisma.AnyNull,
            },
          })
    • 1
    • 2
  • k

    Kenneth Gitere

    03/15/2022, 7:40 AM
    Hi guys. Does anyone use SvelteKit with prisma? I wanted to know the recommended way to handle db connections. I currently have the
    PrismaClient
    instance passed in the hooks.ts file so that all endpoints can access it but I get a warning after some time about having upto 10 instances running. Would it be better to just create a client instance within every endpoint?
    n
    • 2
    • 2
  • k

    Kay Khan

    03/15/2022, 12:07 PM
    Can someone help me align the return types correctly works:
    Copy code
    export const FindUsers = async (): Promise<ReturnType<typeof PrismaService.authentication.findMany> | null> => {
        try {
            const users = await PrismaService.authentication.findMany({
                where: { dtype: "checkpoint_login" },
                include: { user: true, authentication_permission: true },
            });
    
            return users
        } catch (err) {
            Logger.error({ method: "FindUsers", error: err, stack_trace: err.stack });
            return null;
        }
    };
    doesent work: ( im not sure why simplying returning a array breaks this.
    Copy code
    export const FindUsers = async (): Promise<[ReturnType<typeof PrismaService.authentication.findMany> | null, null]> => {
        try {
            const users = await PrismaService.authentication.findMany({
                where: { dtype: "checkpoint_login" },
                include: { user: true, authentication_permission: true },
            });
    
            return [users, null];
        } catch (err) {
            Logger.error({ method: "FindUsers", error: err, stack_trace: err.stack });
            return [null, err];
        }
    };
    Copy code
    1. Type '(authentication & { user: user | null; authentication_permission: authentication_permission[]; })[]' is not assignable to type 'PrismaPromise<authentication[]>'.
         Type '(authentication & { user: user | null; authentication_permission: authentication_permission[]; })[]' is missing the following properties from type 'Promise<authentication[]>': then, catch, finally, [Symbol.toStringTag]
    I want to be able to return an array like above, as i generally call the function using:
    Copy code
    const [usersData, usersError] = await FindUsers();
    h
    a
    • 3
    • 5
  • a

    Ashwin Shenoy

    03/15/2022, 1:35 PM
    Hi everyone 👋 I just released 2 community packages for working with Prisma schema files in Sublime Text. Related discussion https://github.com/prisma/prisma/discussions/12316 If you are using ST for working with schema files, do give these packages a try. Happy to answer any questions as always !
    👍 2
  • c

    Clinton D'Annolfo

    03/15/2022, 4:37 PM
    Hey seems to me like aws-us-east-1.prisma-data.com is down.. no DNS record available?
    😞 1
    n
    • 2
    • 1
  • c

    Cristian Salamea

    03/15/2022, 4:43 PM
    Hi team, I am updating my repo, its an old app and its using 2.5.1, so from today git protocol was full disabled by GitHub https://github.blog/2021-09-01-improving-git-protocol-security-github/ and I found https://github.com/prisma/prisma/blob/2.5.1/src/packages/engine-core/package.json#L47 so should be updated to remove git protocol ?
    n
    • 2
    • 1
  • c

    Cristian Salamea

    03/15/2022, 6:12 PM
    I was trying to find out what’s the branch for 2.5.1 tag? I would like to fix the issue with git protocol
  • m

    Mischa

    03/15/2022, 7:28 PM
    tfw the prisma releases are all about mongo 😞
    😔 2
    f
    • 2
    • 1
  • c

    Chip Clark

    03/15/2022, 7:48 PM
    Adding a record to the db where the record is associated with another record. in the schema: Email - is associated with a Person (PKPersonID), which is also the EntityID
    Copy code
    model Email {
      EmailID        Int       @id @default(autoincrement()) @db.Int
      EntityID?       Int       @db.Int
      EntityTypeID   Int       @db.TinyInt
      EmailAddress   String    @db.VarChar(50)
      EmailTypeID    Int       @db.Int
      Description    String?   @db.VarChar(100)
      Active         Boolean?   @default(false) @db.Bit
      ActiveFromDate DateTime  @db.Date
      ModifiedDate   DateTime?  @default(now()) @db.DateTime
      ModifiedBy     String    @db.VarChar(30)
      ValidFromDate  DateTime?  @db.DateTime2
      ValidToDate    DateTime?  @db.DateTime2
      EmailType      EmailType? @relation(fields: [EmailTypeID], references: [EmailTypeID])
    
      /// One to many relation with Person Entity through EntityID <-> PKPersonID
      Person      Person? @relation(fields: [EntityID], references: [PKPersonID])
    }
    Getting data isn't a problem, but when I try and Create a new email for an existing person: JSON sent to API server
    Copy code
    const tempEmailBody = {
          'EntityID:': PKPersonID,
          'EntityTypeID': 1,
          'EmailAddress': email,
          "ActiveFromDate": this.currentDate,
          "ModifiedDate": this.currentDate,
          "ModifiedBy": "MDD Admin Tool - modified",
          'Active': true
        }
    I get an error:
    Copy code
    Unknown arg `EntityID:` in data.EntityID: for type EmailCreateInput. Did you mean `EntityTypeID`? Available args:
    type EmailCreateInput {
      EntityTypeID: Int
      EmailAddress: String
      Description?: String | Null
      Active?: Boolean | Null
      ActiveFromDate: DateTime
      ModifiedDate?: DateTime | Null
      ModifiedBy: String
      ValidFromDate?: DateTime | Null
      ValidToDate?: DateTime | Null
      EmailType?: EmailTypeCreateNestedOneWithoutEmailInput
      Person?: PersonCreateNestedOneWithoutEmailInput
    if I try and use Person
    Copy code
    const tempEmailBody = {
          'Person:': PKPersonID,
          'EntityTypeID': 1,
          'EmailAddress': email,
          "ActiveFromDate": this.currentDate,
          "ModifiedDate": this.currentDate,
          "ModifiedBy": "MDD Admin Tool - modified",
          'Active': true
        }
    I get the error:
    Copy code
    Unknown arg `Person:` in data.Person: for type EmailCreateInput. Did you mean `Person`? Available args:    
    type EmailCreateInput {                                                                                    
      EntityTypeID: Int                                                                                        
      EmailAddress: String                                                                                     
      Description?: String | Null                                                                              
      Active?: Boolean | Null                                                                                  
      ActiveFromDate: DateTime                                                                                 
      ModifiedDate?: DateTime | Null                                                                           
      ModifiedBy: String                                                                                       
      ValidFromDate?: DateTime | Null                                                                          
      ValidToDate?: DateTime | Null                                                                            
      EmailType?: EmailTypeCreateNestedOneWithoutEmailInput                                                    
      Person?: PersonCreateNestedOneWithoutEmailInput                                                          
    }
    IF I try and build something that creates a PersonWhereUniqueInput
    Copy code
    const tempEmailBody = {
          'Person:': {'PersonWhereUniqueInput': {PKPersonID: this.onePerson.PKPersonID} },
          'EntityTypeID': 1,
          'EmailAddress': email,
          "ActiveFromDate": this.currentDate,
          "ModifiedDate": this.currentDate,
          "ModifiedBy": "MDD Admin Tool - modified",
          'Active': true
        }
    I get the error:
    Copy code
    Unknown arg `Person:` in data.Person: for type EmailCreateInput. Did you mean `Person`? Available args:
    type EmailCreateInput {
      EntityTypeID: Int
      EmailAddress: String
      Description?: String | Null
      Active?: Boolean | Null
      ActiveFromDate: DateTime
      ModifiedDate?: DateTime | Null
      ModifiedBy: String
      ValidFromDate?: DateTime | Null
      ValidToDate?: DateTime | Null
      EmailType?: EmailTypeCreateNestedOneWithoutEmailInput
      Person?: PersonCreateNestedOneWithoutEmailInput
    }
    j
    • 2
    • 3
  • m

    Manthan Mallikarjun

    03/15/2022, 8:27 PM
    Should probably update the announcement post to specify that the document filters are for mongodb
    👌🏽 1
    a
    • 2
    • 2
  • a

    aj

    03/15/2022, 8:39 PM
    Hi, how can I
    connectOrCreate
    where multiple fields match. Or how can I use
    where: {AND: [{},{}]}
    operation inside
    connectOrCreate
    ?
    n
    • 2
    • 2
  • m

    Mounir Bennacer

    03/15/2022, 9:17 PM
    can someone share an implementation of the PostgreSQL Daterange please ? I'm having a hard time getting it to works something like this
    Copy code
    prisma.$queryRaw`
    SELECT *
    FROM MyTable
    WHERE COMPANY_ID = 1
    AND "[2020-01-01,2020-12-31]"::daterange @> during
    GROUP BY 1
    ORDER BY 1 ASC`
    something like that where the date range is inclusive of bounds ( aka getting the whole day until 2020-12-31 000000 for say )
    n
    • 2
    • 1
  • d

    Demian N

    03/16/2022, 2:25 AM
    Is there a method on where I can save the current state (data) of my db (like postgresql SAVEDPOINT), then make some queries and mutatiosns and finally rollback to that savedpoint. This would be very handy in E2E tests so I can I always start with the same state of data between tests. Is there a way people is doing this with prisma?
    n
    • 2
    • 1
  • m

    Moh

    03/16/2022, 7:42 AM
    Hey guys, got an existing project running prisma 2.26. Did a fresh git clone, running npm i I am getting: No matching version found for @prisma/engines-version@2.30.1-2.b8c35d44.... Any help?
    n
    • 2
    • 1
  • d

    Damian M

    03/16/2022, 8:17 AM
    Hey guys looking for some typescript help. I have a dynamic upsert function like so
    Copy code
    ctx.prisma[`${var)Model`].upsert(....
    Typescript automatically creates a union with the variable possiblities but as these models have different fields I get an error like
    Copy code
    Each member of the union type '(<T extends  ....  ..... => CheckSelect<...>)' has signatures, but none of those signatures are compatible with each other.
    Is there anyway to fix this problem?
    m
    • 2
    • 3
  • l

    Ludde Bror

    03/16/2022, 11:42 AM
    I'm using VS Code with the Prisma extension. I'm also using Next.js with javascript and not typescript. When I'm doing a CRUD operation it would be handy if a model could be shown in VS Code, so you wouldn't have to lookup your model in the schema, while coding. Can I make it happen with some settings somewhere? Else it's a proposal/feature request from my side to add for the extension or the package. I think it would be very useful
    const newOrder = await prisma.Order.create({
    data: {
    // Hmm... How did the Order model look like again..? Do I really have to go to my schema to view it? can't it be shown in VS code when hovering "Order" or while typing?
    },
    });
    Would you like me to create a feature request of this on github?
    n
    • 2
    • 6
  • m

    Madhusha Prasad

    03/16/2022, 12:16 PM
    Hello everyone iam madhusha
    👋 1
  • m

    Michael Roberts

    03/16/2022, 12:26 PM
    Hey, I’m wondering about how we get intellisense with Typescript … so if I have a model named say users, I can see this on the prisma object …
    n
    • 2
    • 2
  • r

    Ricardo Ferreira

    03/16/2022, 12:44 PM
    Hi everyone! 👋
    👋 1
  • c

    Cristian Salamea

    03/16/2022, 1:42 PM
    Hi everyone! I would like to fix something in old version, specific 2.5.1 since GitHub full disabled git protocol yesterday, I checked the code and I didn’t find branch for 2.5.1 tag, so can anyone help me to find it? to remove this git ref https://github.com/prisma/prisma/blob/8e8412d6419de1f2691d00e9cc0d740de7f729b0/src/packages/engine-core/package.json#L47
    j
    • 2
    • 2
  • j

    Julien Goux

    03/16/2022, 3:39 PM
    Hello, we have a weird case with connection pooling and interactive transactions. We have a pool size of max 3 connections. We open an interactive transaction and also execute queries that aren’t bound to this transaction at the same time
    d
    • 2
    • 16
  • j

    Julien Goux

    03/16/2022, 4:04 PM
    For how long does Prisma keep idle connections around in the context of postgresql?
    d
    • 2
    • 12
  • b

    Bryson Kruk

    03/16/2022, 5:37 PM
    Hello, I'm attempting to migrate my backend from Sequelize to Prisma, and referring to this doc: https://www.prisma.io/docs/concepts/more/comparisons/prisma-and-sequelize The very first thing I'd like to do now that it's installed and is make Prisma the source for migrations. Even after running an introspection though, when I first run a migration, it seems like I MUST delete all my data in the postres DB. This is locally on dev by the way. Is there any way to do this without losing all my data?
    k
    j
    • 3
    • 3
1...554555556...637Latest