Lewis
08/29/2022, 1:09 PMmodel User {
id String @id @unique
rewardsId String @unique
rewards Rewards @relation(fields: [rewardsId], references: [id])
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Rewards {
id String @id @unique
user User?
test Int @default(0)
}
Hello! I need some help and can't seem to find the answer online. I'm trying to create a 1-1 relation and have the "Rewards" table automatically populate once I create a User like this: user.create({data: {id: "id"}})
Without having to specify in code to also create the Rewards table?
I'm also wondering how when the Rewards table is created it can share the id from User?
Also... is there a way to edit the DateTime default to be something other than "now" in the schema? Say 24 hours in the past?Stanislas de Roquemaurel Galitzine
08/29/2022, 1:58 PMDondo Chaka
08/29/2022, 5:59 PMtarget_type
and target_id
with relations to the corresponding User
and Channel
models (not shown)?
model Topic {
id Int @id @default(autoincrement())
name String
description String?
publishers Communicator[] @relation("publisher")
subscribers Communicator[] @relation("subscriber")
}
model Communicator {
id Int @id @default(autoincrement())
target_type CommunicatorType
target_id Int
publishable Topic[] @relation("publisher")
subscriptions Topic[] @relation("subscriber")
}
enum CommunicatorType {
USER
CHANNEL
}
Filipe
08/29/2022, 8:04 PMenum StoreNames {
GlobalData
PcDiga
PcComponentes
}
model Store {
id String @id @default(cuid())
name StoreNames
product_url String @default("")
price Float @default(0)
discount Int?
availability Boolean?
created_at DateTime @default(now())
updated_at DateTime @updatedAt
}
model Cpu {
id String @id @default(cuid())
product_type String @default("cpu")
name String
abrev String
created_at DateTime @default(now())
updated_at DateTime @updatedAt
}
model Motherboard {
id String @id @default(cuid())
product_type String @default("motherboard")
name String
abrev String
created_at DateTime @default(now())
updated_at DateTime @updatedAt
}Timothy Choi
08/29/2022, 9:00 PMClƩment Guibout
08/29/2022, 9:00 PMmodel Pinpoint {
id String @id @default(cuid())
name String
description String?
carrousel Image[]
date DateTime?
latitude Float
longitude Float
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Image {
id String @id @default(cuid())
name String
description String?
image String
pinpoint Pinpoint @relation(fields: [pinpointId], references: [id], onDelete: Cascade)
pinpointId String
}
And I am trying to create a new pinpoint with the associated image carrousel using TRPC and Prisma
Here is my attempt (that should work?)
export const pinpointRouter = createRouter()
.mutation("createPinpoint", {
input: z.object({
name: z.string(),
description: z.string().optional(),
carrousel: z.array(z.object({
name: z.string(),
description: z.string().optional(),
image: z.string(),
})).optional(),
date: z.date().optional(),
latitude: z.number(),
longitude: z.number()
}),
async resolve({ ctx, input }) {
try {
await ctx.prisma.pinpoint.create({
data: {
name: input.name,
description: input.description,
carrousel: {
create: input.carrousel
},
date: input.date,
latitude: input.latitude,
longitude: input.longitude,
},
include: {
carrousel: true
}
})
} catch (error) {
console.log(error)
}
}
});
I am first describing the zod schema I want tRPC to validate, and the I try to effectively create the record in the database
But the carrousel create instruction tells me that Type '{ description?: string | undefined; name: string; image: string; }[] | undefined' is not assignable to type '(Without<ImageCreateWithoutPinpointInput
, where the former is my actual carrousel that I receive on the API, and the later is what should be described in the database.
Aren't these two things the exact same type?David Ilizarov
08/29/2022, 10:43 PMprisma.document.update({
where: {
id, //unique
creatorId: session.userId, // non-unique
state: "DRAFTING" // non-unique
}
})
Seems really really strange you can't do this. Yes, a unique row stays required. Worst case is you don't find a row that meets those conditions and do nothing.
My case is rather minor, but there are other cases where without this, race-conditions and security vulnerabilities are introduced.Ilkka Huotari
08/30/2022, 12:32 AM@unique
, it can still create multiplerecords that have the same value in that @unique
field. It throws an error when I'm doing that do id
field, but doesn't throw if I do it with another @unique
field.
So, it seems to ignore that @unique
setting for all the other fields than id
.
Solution: I had to create a unique index in Mongo shell to make the unique thing work.Rain
08/30/2022, 12:57 AMPetr SlavĆk
08/30/2022, 8:53 AMpool_timeout=30&connect_timeout=30
, it ends up with errorCode: P2024, Timed out fetching a new connection from the connection pool.
Now the strange part:
ā Local machine - Connection works perfectly from Firebase Emulator -> connection string is valid
ā Remote Firebase Function - I can successfully connect to that DB via https://github.com/sidorares/node-mysql2 with same credentials -> nothing is preventing connection from the Firebase Function
So the question is, why can't I connect with Prisma while I can with mysql2?
I am using Prisma 4.2.1.Anthony
08/30/2022, 9:45 AMIlkka Huotari
08/30/2022, 11:02 AMMessage: Error in Prisma Client request:
Maximum call stack size exceeded
Query:
{
"modelName": "Email",
"operation": "findMany",
"args": {
"take": 100,
"skip": 0,
"select": {
"id": true,
"uid": true,
"userId": true,
"contactId": true,
"contactStatus": true,
"messageId": true,
"to": true,
"cc": true,
"bcc": true,
"createdAt": true,
"updatedAt": true,
"headers": true,
"subject": true,
"text": true,
"html": true,
"textAsHtml": true,
"exct": true,
"files": true,
"tags": true,
"status": true
}
}
}
Travis James
08/30/2022, 11:04 AMgenerate
action), which is powerful when considering the need for mobile applications to implement offline operation in a transparent way. One key to this for me, however, is the need to encrypt data at rest using SQLCipher. The Prisma Engine has the capability to do this thanks to updates made to rusqlite
that provides support for integrating SQLCipher, but the engine currently does not expose a way to provide keys for decryption (which would be stored securely on the device elsewhere). The question I have is this: is making this change interesting enough to add to the prisma-engines project once I have completed the work?MƔrcio Martins
08/30/2022, 2:16 PMconnect
. This is working for all my other models, but somehow it is not working for this one.Paul Van Dyk
08/30/2022, 2:18 PMIdentitySlug
should always be unique, and only exist in one Company entry or one User entry.
I'm unsure how to setup the relationship for this, or even if it's possible to setup a relationship for this?
I'm using mysqlTed Joe
08/30/2022, 3:59 PMprisma chobo
08/30/2022, 5:27 PMDavid Brands
08/30/2022, 6:07 PMEnnabah
08/30/2022, 7:07 PMDonald MartĆnez Arancibia
08/30/2022, 7:43 PMIgnatius Hefer
08/30/2022, 7:45 PMDEBUG=knex*
Output:
knex:client acquired connection from pool: __knexUid1 +0ms
knex:query select * from "mytable" undefined +0ms
knex:bindings [] undefined +0ms
knex:client releasing connection to pool: __knexUid1 +610ms
PRISMA
prismaClient.$on("query", (e) => {
console.log(e);
});
Output:
{
timestamp: 2022-08-30T19:32:49.399Z,
query: 'select * from mytable',
params: '[]',
duration: 955,
target: 'quaint::connector::metrics'
}
I'm consistently loosing 30 - 50% in performance... Can someone tell me what I'm missing or am I looking at these values wrong?R2D2
08/30/2022, 10:01 PM<https://binaries.prisma.sh/all_commits/2920a97877e12e055c1333079b8d19cee7f33826/debian-openssl-1.1.x/introspection-engine.gz.sha256>
afted 3 days of debuggind, router firmware upgrading, stracing and tcpdumping I find that:
domain binaries.prisma.sh
could be resolved to 2 different ips
108.156.22.32 (<http://server-108-156-22-32.hel51.r.cloudfront.net|server-108-156-22-32.hel51.r.cloudfront.net>)
108.156.22.92 (<http://server-108-156-22-92.hel51.r.cloudfront.net|server-108-156-22-92.hel51.r.cloudfront.net>)
and 108.156.22.32
did not response on :443
port
Im trying from different networks and network providers, its not working. But working only trought vpn in other country.
(but 22.92
always response succsesfully)
(Very annoing thing that makes CI process up to one hour until all TIMEOUTS returns š«)
Command to repro:
curl <https://binaries.prisma.sh/all_commits/2920a97877e12e055c1333079b8d19cee7f33826/debian-openssl-1.1.x/prisma-fmt.sha256> -v --resolve 'binaries.prisma.sh:443:108.156.22.32'
* Added binaries.prisma.sh:443:108.156.22.32 to DNS cache
* Hostname binaries.prisma.sh was found in DNS cache
* Trying 108.156.22.32:443...
...
TIMEDOUT
R2D2
08/30/2022, 10:06 PMGabriel
08/30/2022, 11:39 PMSELECT CONCAT(FirstName, ' ', LastName) AS FullName FROM Users
?João Vitor Casarin
08/31/2022, 1:31 AMfindFirst
returns null
when not found, create
apparently throws if record exists, update
throws RecordNotFound
when failure, delete
throws RecordNotFound
when failure, what is the advise to standardize these responses? Should I catch the errors and return null
instead of those throws, or analyze if the response is null
and then throw my own error, or what?João Vitor Casarin
08/31/2022, 1:34 AMAlex
08/31/2022, 7:52 AMAlex
08/31/2022, 7:52 AMqueryRaw
Ali
08/31/2022, 8:33 AMprovided value for the column is too long for the column's type. Column: (not available)
Do you know where the problem might come from?Ali
08/31/2022, 8:56 AM