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

    doddy nicolas

    09/27/2022, 2:54 PM
    is prisma support spatial data with mysql?
    ✅ 1
    r
    • 2
    • 1
  • a

    Alix A

    09/27/2022, 3:01 PM
    I was wondering if someone could help me figure this out. I have a Node application using a Postgres database with PostGIS running inside a docker container. Whenever Prisma tries to connect to it, I get the error `P1001: Can't reach database server at `localhost`:`15432``. I can connect to it fine using some database management tools, and I can connect to deployed Postgress database using PostGIS just fine. Below is my docker-compose file and the connection string.
    Copy code
    version: '3.8'
    
    services:
      postgres:
        container_name: test-postgres
        image: kartoza/postgis:14-3.3--v2022.08.30
        ports:
          - 15432:5432
        environment:
          - POSTGRES_USER=admin
          - POSTGRES_PASSWORD=secret
          - POSTGRES_DB=test-db
        volumes:
          - postgis-data:/var/lib/postgresql
    
    volumes:
      postgis-data:
    Copy code
    DATABASE_URL="<postgresql://admin:secret@localhost:15432/test-db?schema=public>"
    ✅ 1
    👀 1
    n
    • 2
    • 1
  • d

    doddy nicolas

    09/27/2022, 3:40 PM
    how to store a geolocated data with prisma to mysql
    ✅ 1
    r
    • 2
    • 2
  • g

    guilherme

    09/27/2022, 4:07 PM
    hello guys im trying to return the number of records nested in one model on my database but i am not finding a way. where i want just the number of record where notifications is dismissAt null. but i just want the number not the whole thing.
    Copy code
    const user = await this.prismaService.user.findUnique({
          where: {
            id: userId,
          },
          select: {
            managing: {
              select: {
                user: {
                  select: {
                    person: true,
                  },
                  include: {
                    notifications: {
                      where: {
                        dismissAt: null,
                      },
                    },
                  },
                },
              },
            },
          },
        });
    ✅ 1
    r
    • 2
    • 4
  • i

    Irakli Safareli

    09/27/2022, 7:52 PM
    Can Prisma maintainers give directions on how to implement this: https://github.com/prisma/prisma/issues/10425? I’m happy to contribute
    👀 1
    ✅ 1
    n
    • 2
    • 1
  • c

    Collin

    09/27/2022, 8:01 PM
    Hi I'm trying to output a decimal type from prisma as a number type. I'm trying to map my prisma result to a GRPC response and i need my output from prisma to be in the number type.
    👀 1
    a
    v
    • 3
    • 2
  • a

    Austin

    09/27/2022, 10:02 PM
    Hi @Jamie Higgins 👋, What IDE are you using? I know when I hit weird issues, they usually go away after restarting the TypeScript Language Server and sometimes the IDE itself.
    v
    • 2
    • 1
  • m

    Michael

    09/27/2022, 11:25 PM
    is
    OR
    actually functional? there's no OR present in the generated SQL and instead it seems to be generating the same SQL as when the OR is an AND:
    Copy code
    await prismaClient.objective.findMany({
          where: {
            patientId: id,
            OR: { // replace with AND makes no difference
              branchingOptionId: { not: null },
              conversationItemId: { not: null },
            },
          },
        });
    
     // generates: SELECT Objectives.id, ... WHERE (Objectives.patientId = 1 AND Objectives.branchingOptionId IS NOT NULL AND Objectives.conversationItemId IS NOT NULL)
    tested in 4.3.1 and 4.4.0, using mysql. Seems to happen for any query with OR in it
    ✅ 1
    j
    • 2
    • 12
  • a

    Amgelo563

    09/28/2022, 12:40 AM
    I'm getting this when trying to call JSON.parse() on a fetched Json property
    Copy code
    TS2531: Object is possibly 'null'.
    TS2345: Argument of type 'JsonValue' is not assignable to parameter of type 'string'.   Type 'null' is not assignable to type 'string'.
    What confuses me is that • Wasn't JsonValue made to always support JSON.parse()? • Why would JsonValue be null if my schema says it's required? I tried to use
    Copy code
    JSON.parse(fetchedValue ?? '{}');
    but I get
    Copy code
    TS2345: Argument of type 'string | number | boolean | JsonObject | JsonArray' is not assignable to parameter of type 'string'.   Type 'number' is not assignable to type 'string'.
    which is related to the first mentioned point. Could someone explain to me what is going on? I probably missed something on the wiki or I did something wrong
    👀 1
    n
    • 2
    • 6
  • l

    Lucas Pelegrino

    09/28/2022, 12:48 AM
    What’s up everyone! Is there any way to overwrite the original Prisma logger with my own? I can find in the docs a reference to logging with Prisma, but not sure if it’s possible to have Prisma use my own logger by default. I tried using this:
    Copy code
    this.$on('query', (event) => {
      this.logger.debug(`Query: ${event.query}`, PrismaService.name);
    }
    It duplicates the logs, one time with my custom logger and one time (logged first) with prisma’s default one.
    ✅ 1
    n
    • 2
    • 2
  • n

    Nurul

    09/28/2022, 6:41 AM
    Hey @Jose Antonio Amieva Cardoso 👋 Welcome to our community! prisma rainbow Which framework are you using to create your frontend application?
    • 1
    • 1
  • h

    Henrik Spolander

    09/28/2022, 8:24 AM
    Hi, I am using Prisma with Remix(TypeScript). I have an issue where my
    DateTime
    's are returned to me as strings. I understand this is how it works when writing in TypeScript but does it mean I have to define the types on the client differently than the models I defined for Prisma? Is there a best practice for solving this? Model:
    Copy code
    model Review {
      id          String   @id @default(uuid())
      createdAt   DateTime @default(now())
      updatedAt   DateTime @updatedAt
      comment     String
      score       Int
      wine        Wine @relation(fields: [wineId], references: [id], onDelete: Cascade)
      wineId      String
      reviewer    WineUser @relation(fields: [userId], references: [id], onDelete: Cascade)
      userId      String
    }
    Query:
    Copy code
    let db: PrismaClient;
    //Prismaclient is imported from elsewhere
    
    ...
    
    const reviews = await db.review.findMany({
        take: 1,
      });
    console.log({reviews})
    Log:
    Copy code
    reviews: [
        {
          id: '00715d17-19ea-429d-8d04-cc0afe4f0b53',
          createdAt: '2022-09-27T18:46:08.953Z',
          updatedAt: '2022-09-27T18:46:08.953Z',
          comment: 'Mycket prisvärt. Viss fatkaraktär. Körsbärstoner. Inte så kraftigt.\n' +
            'Alk.: 13.50%',
          score: 7,
          wineId: '5b4fd795-4c82-4b78-b568-eb72754f6ab2',
          userId: '8a65f07b-6357-45b4-9fb7-c13ca989053a'
        }
      ]
    ✅ 1
    n
    v
    • 3
    • 4
  • k

    Kashyup

    09/28/2022, 10:00 AM
    Hi all! I'm trying to save data in my prisma studio but its not allowing to save it.
  • k

    Kashyup

    09/28/2022, 10:01 AM
    here's my prisma model: model Video { id Int @id @default(autoincrement()) videoUrl String videoAnalytics VideoAnalytics? } model VideoAnalytics { id Int @id @default(autoincrement()) name String createdAt DateTime @default(now()) updatedAt DateTime @default(now()) ImpressionData Int impression Video @relation(fields: [impressionId], references: [id]) impressionId Int @unique }
    👀 1
    ✅ 1
    r
    v
    • 3
    • 4
  • y

    Yudhvir Raj

    09/28/2022, 10:58 AM
    Hi, I've been looking at how I can automate the process from schema to graphql schema. Unfortunately, using the generators currently, it has security risks & does not work well with computed properties (i.e full name from first name & last name). Additionally, I cannot regenerate the classes as it will override any changes. So I want to look into making custom decorators for the prisma schema. An example would be
    Copy code
    model User {
        @ComputedProperty(firstName, lastName)
        fullName string
    }
    Does Prisma support such functionality or does it intend too in the future?
    ✅ 1
    j
    • 2
    • 3
  • o

    Omri Goldberger

    09/28/2022, 11:39 AM
    Hey, I've got a question: If your DB sits in AWS private subnet, how can you connect Prisma Data Proxy to it?
    😭 1
    ✅ 1
    n
    • 2
    • 5
  • n

    Nurul

    09/28/2022, 12:31 PM
    Hey @ven v 👋 Is
    prisma generate
    command included in your build step? For example, here’s the package.json file in a sample repository which demonstrates deploying a next.js app with Prisma to vercel.
    v
    • 2
    • 1
  • m

    Matheus Assis

    09/28/2022, 3:01 PM
    Is there a rss for the prisma updates/announcements? I want to add a bot to the company’s slack channel that posts a new message on each major release
    ✅ 1
    n
    • 2
    • 1
  • d

    Dale Shanefelt

    09/28/2022, 7:25 PM
    Hello - I am trying to run a prisma db pull and am getting Error: Error parsing connection string: invalid port number in database URL . I have in my .env file: DATABASE_URL="mysql://graphqluser:realpassworddeleted@128.2.172.9:3306/applygradgraphql" Any thoughts?
    ✅ 1
    m
    j
    • 3
    • 5
  • p

    Paulo Castellano

    09/28/2022, 9:22 PM
    What’s wrong on this connect? User already exists
    Copy code
    const website = await prisma.website.create({
          data: {
            name: name,
            domain: domain,
    
            users: {
              connect: {
                userId: userId,
                role: 'owner'
              }
            },
          },
        })
    a
    • 2
    • 13
  • r

    Rob

    09/29/2022, 4:47 AM
    Copy code
    No cast exists, the column would be dropped and recreated, which cannot be done since the column is required and there is data in the table.
    Is there no way I can just get it to add the column, but fill out a default value to fulfill the requirements?
    ✅ 1
    n
    • 2
    • 6
  • a

    Amit Kumar

    09/29/2022, 7:20 AM
    So we were making a microservice in nestJS and using prisma for the ORM. Our existing app is on rails so it's default ORM understands that:
    user_id
    in the table
    user_posts
    is a reference to the table
    users
    . So when I introspect the database, schema like the following is generated, where it doesn't implicitly knows the relations
    Copy code
    model users {
      id               BigInt   @id @default(autoincrement())
      user_name        String?  @db.VarChar
      tenant_id  	   Int?
    }
    
    model user_posts {
      id                BigInt    @id @default(autoincrement())
      post_id           Int?
      user_id           Int?
      tenant_id  		Int?
    }
    Any solution for this other than declaring each supposed foreign key in the main database?
    👀 1
    r
    v
    • 3
    • 7
  • t

    Theo Letouze

    09/29/2022, 10:48 AM
    Hey guys, I have a huge table in dev db with a script to seed it but it takes 1hour to run. I wanted to know how would you resolve schema drift in my case ? For example if another branch change the db schema I can’t run others migrations because of the schema drift (I’ve seen in the doc that it resolve this by reset the database but in my case I have to wait 1 hour to seed it)
    👀 1
    r
    v
    a
    • 4
    • 34
  • j

    Jarupong

    09/29/2022, 11:56 AM
    I think you mean recursive association? Post -> Comment -> Post
    v
    r
    • 3
    • 13
  • v

    ven v

    09/29/2022, 6:12 PM
    Say I wanna create a table with RLS. what do i need to do in the schema?
    Copy code
    create table todos (
      id bigint generated by default as identity primary key,
      user_id uuid references auth.users not null,
      task text check (char_length(task) > 3),
      is_complete boolean default false,
      inserted_at timestamp with time zone default timezone('utc'::text, now()) not null
    );
    alter table todos enable row level security;
    create policy "Individuals can create todos." on todos for
        insert with check (auth.uid() = user_id);
    create policy "Individuals can view their own todos. " on todos for
        select using (auth.uid() = user_id);
    create policy "Individuals can update their own todos." on todos for
        update using (auth.uid() = user_id);
    create policy "Individuals can delete their own todos." on todos for
        delete using (auth.uid() = user_id);
    something like this, how to do in prisma?
    ✅ 1
    a
    • 2
    • 3
  • c

    Chris Graves

    09/29/2022, 7:01 PM
    is it possible to have prisma directly build the schema in an empty database directly from the prisma file, instead of having to create the migration? the use case is a local test database that i’m running integration tests against and when when making small changes to the prisma file, the step of creating a migration is one too many. i’m looking for a way to rebuild the database from scratch based on the current contents of the prisma file (i’ll make the migration later, once the changes are settled and tested)
    ✅ 1
    f
    n
    • 3
    • 4
  • f

    Fergal Moran

    09/29/2022, 7:02 PM
    Hello all, I'm trying to use the preview filteredRelationCount feature and I have a question. How can I perform two counts on the same column with a different filter?
    Copy code
    const items = await prisma.items.findMany({
        take: 12, orderBy: { title: 'asc' },
        include: {
            _count: {
                select: {
                    votes: { where: { isUp: true } },
                    votes: { where: { isUp: false } }, // ???
                }
            }
        }
    });
    like, I would like the two votes fields to be "upVotes" and "downVotes"? Thanks for any help!
    ✅ 1
    n
    • 2
    • 2
  • g

    Guids

    09/29/2022, 8:13 PM
    Hi there, I'm new to prisma. Can specific generators in a prisma schema be run instead of all of them? Can the generators receive cli flags that can change the output (eg: location, specific models affected, etc)?
    👀 1
    n
    v
    • 3
    • 2
  • c

    Collin

    09/29/2022, 8:38 PM
    I need help joining a decimal type on a string. We before were able to run query that could join a decimal on a string. Now with using prisma my schema is invalid when i try joining these two different data types.
    👀 1
    n
    • 2
    • 3
  • r

    Rob

    09/30/2022, 5:34 AM
    Does prisma really not have virtual fields? Kind of punching myself because I switched over to prisma from sequelize, only to realize that sequelize seems to have everything I was looking for.
    👀 1
    v
    • 2
    • 3
1...626627628...637Latest