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

    Ethan Pursley

    04/15/2020, 11:59 PM
    if you need subscriptions, you should move to something like hasura, that was the advice my team got from a prisma engineer
  • c

    Charlie Meaden

    04/16/2020, 12:04 AM
    And migrations, updating the DB is all easy?
  • c

    Charlie Meaden

    04/16/2020, 12:04 AM
    and we just do a quick rewrite and hook that up to our graphql layer that is currently in node
  • c

    Charlie Meaden

    04/16/2020, 12:05 AM
    We have Postgress > Prisma > Graphql > Web App + Mobile App
  • e

    Ethan Pursley

    04/16/2020, 12:06 AM
    if you use join tables, moving to anything will be pretty hard, so hopefully you only use inline connections
  • c

    Charlie Meaden

    04/16/2020, 12:07 AM
    yes we have not used any links
  • e

    Ethan Pursley

    04/16/2020, 12:07 AM
    hasura would connect to postgres and basically act as your backend as they remove the need for a node backend in most cases.
  • e

    Ethan Pursley

    04/16/2020, 12:07 AM
    you would protect your data with claims in your jwt
  • c

    Charlie Meaden

    04/16/2020, 12:08 AM
    so essentially we would remove the graphql layer
  • e

    Ethan Pursley

    04/16/2020, 12:15 AM
    no, sorry, hasura is graphql.
  • a

    AlexZp

    04/16/2020, 11:14 AM
    Hi, guys. I have an issue with datamodel.prisma (I think):
    enum Permission {
    ADMIN
    USER
    ITEMCREATE
    ITEMUPDATE
    ITEMDELETE
    PERMISSIONUPDATE
    }
    type User {
    id: ID! @id
    name: String!
    email: String! @unique
    password: String!
    resetToken: String
    resetTokenExpiry: Float
    createdAt: DateTime! @createdAt
    updatedAt: DateTime! @updatedAt
    permissions: [Permission!]! @scalarList(strategy: RELATION)
    }
    and then I create a mutation with query
    ctx.db.query.user({ where: { email } });
    but get return without
    permissions
    field. "message": "Cannot return null for non-nullable field User.permissions." On prisma.io server, User have this field with a set value
    a
    • 2
    • 1
  • s

    sdy

    04/16/2020, 1:38 PM
    Hi guys, prisma 2 doesn’t have docker image? i wanna make my backend project with docket and prisma 2. but prisma 2 image doesn’t exit in docker hub
    r
    k
    • 3
    • 2
  • d

    dek sch

    04/16/2020, 1:42 PM
    Hi, I haven't found info about it in the docs: • Is it possible to change a scalar type field to an array of the same type, without losing the data?
    r
    • 2
    • 2
  • k

    KJReactor

    04/16/2020, 2:43 PM
    When will Prisma v2 have MongoDB support?
    r
    • 2
    • 2
  • a

    AlexZp

    04/16/2020, 3:43 PM
    Is anybody can help me? https://prisma.slack.com/archives/CA491RJH0/p1587035647124300
  • a

    Alan

    04/17/2020, 4:08 AM
    Now, I have 1 database with Prisma. Models: `User`/`Post`/`Log` The database is starting to be huge, because of the table
    Log
    . What would be the Prisma architecture to have 2 distincts databases (`User`/`Post` and
    Log
    )
    r
    • 2
    • 1
  • d

    Daan Helsloot

    04/17/2020, 8:05 AM
    Hi there, Is there any information available on how to create a relationship on oneself with Prisma 2?
    u
    • 2
    • 2
  • s

    stephan

    04/17/2020, 8:24 AM
    Is there a way to create the entities relation tree ?
    r
    • 2
    • 2
  • c

    Chad H

    04/17/2020, 11:02 AM
    Does anyone have instruction on how to backup and restore prisma PG database? I could never get it right and prisma always return errors Thx!
    r
    c
    • 3
    • 5
  • j

    James Homer

    04/17/2020, 6:01 PM
    Does anyone have any smart workarounds for json fields when upgrading a prisma1 project?
  • m

    Matt

    04/17/2020, 6:26 PM
    Hi, I have a question about nesting includes and selects. As an example, I have Table A with several feeds including a relation field that connects it to Table B. If I say
    Copy code
    ...
    				return ctx.prisma.TableA
    					.findMany({
    						where: {
    							...
    						},
    						include: {
    							TableBconnectionField: true					},
    					})
    ...
    I get all the fields in Table A and all the fields in Table B. But I also have a connection field in Table B to Table C and I need some data from that included in the return JSON as well. If I put
    Copy code
    ...
    				return ctx.prisma.TableA
    					.findMany({
    						where: {
    							...
    						},
    						include: {
    							TableBconnectionField: {
    								select: { field_1: true, field_2: true, TableCconnectionField: true },
    							}
    						},
    					})
    ...
    I get all the fields for Tables A and C but only get field_1 and field_2 for Table B. Is there a way to do this that gives me all the fields for Table B as well without me having to explicitly request them?
    • 1
    • 2
  • a

    Alp Karavil

    04/17/2020, 6:46 PM
    Hey everyone, I'm trying to display a many to many relation (I guess it's one to many in this one) for a GET request. Is there a better way of doing it other than searching the db twice? How would I chain the .resources() call to the first function?
    Copy code
    app.get(`/projects/:id`, async (req, res) => {
       const { id } = req.params;
       const project = await prisma.project.findOne({
          where: {
             id: Number(id),
          },
       });
       const resourcesOfProject = await prisma.project
          .findOne({ where: { id: Number(id) } })
          .resources();
       res.status(200).json({ ...project, resources: resourcesOfProject });
    });
    
    // Here is some of my schema
    model Resource {
      id          Int       @default(autoincrement()) @id
      name        String
      description String?
      projects    Project[] @relation(references: [id])
    }
    
    model Project {
      id          Int        @default(autoincrement()) @id
      name        String
      description String?
      tasks       Task[]
      resources   Resource[] @relation(references: [id])
      completed   Boolean    @default(false)
    }
    m
    • 2
    • 3
  • a

    Adriano Resende

    04/17/2020, 10:20 PM
    What is the best way to fill the new column for existing rows? The migration CLI is able to do this?
  • a

    Adriano Resende

    04/17/2020, 10:21 PM
    Use @default and then remove @default after up?
    r
    • 2
    • 2
  • b

    Brendan Dolan

    04/17/2020, 10:46 PM
    Hi all. Great to be here. 😀 I'm wondering, what might be the best way to change the datasource URL in production on Google Cloud?
    r
    • 2
    • 2
  • b

    Brendan Dolan

    04/17/2020, 11:55 PM
    Actually, I'm going nuts. What is the alternative to using an .env file when the schema.prisma file isn't JS?
  • v

    Vince Biro

    04/17/2020, 11:56 PM
    What do you suggest for security when using raw queries against SQL injection? I am looking for some escape function. If possible, a solution from prisma would be the best, otherwise from another dependency
  • m

    Matt

    04/18/2020, 12:02 AM
    I have a question about chaining include or select statements. I want to make query that pulls a list of items and gets data from 3 or more levels. For example, I have this query:
    Copy code
    return ctx.prisma.lead
    					.findOne({
    						where: args,
    						include: {
    							User: true,
    							LeadCampaign: { include: { LeadSource: true } },
    						},
    					})
    It successfully pulls the right row from the lead table and also the associated row from the associated LeadCampaign table and the correct row for the LeadSource that's associated with it. However, when I try to get a list of leads with their associated data like so:
    Copy code
    return ctx.prisma.lead
    					.findMany({
    						where: args,
    						include: {
    							User: true,
    							LeadCampaign: { include: { LeadSource: true } },
    						},
    					})
    I get the error:
    Expected at most 1 item for 'LeadSource', got 21
    I found in the documentation that "_The only requirement for chaining is that the previous function call must return only a single object (e.g. as returned by a 
    findOne
     query or a "to-one relation" like 
    profile.user()
    )._" So I get that it can't pull a list of items from a parent that was also a list, but each lead has only one LeadCampaign and each LeadCampaign only has one LeadSource, so it seems like it's meeting the "to-one relation" part of that statement. Do I need to write it differently? Or do I need to write a function to pull different queries and stitch the results together myself?
  • a

    Aman Chaudhary

    04/18/2020, 7:21 AM
    Hi all 👋 I have a question about the docker-compose file and the prisma config. Currently I’m passing a lot of sensitive data (like db username, password, management secret) in docker-compose file. Is there a best practice on how do extract those away into a separate file or usually you guys just exclude it in .gitignore?
    r
    • 2
    • 3
  • o

    omnyx2

    04/18/2020, 1:50 PM
    Hi all I want to know that can we use Prisma2 for GraphQL?(postgres) If not, could you plz tell me why it's impossible. Thanks!
    👍 1
1...365366367...637Latest