Clément Guibout
08/13/2022, 2:27 PMevt_id
)Clément Guibout
08/13/2022, 2:28 PMDor Meiri
08/13/2022, 8:19 PMSELECT AVG(LENGTH(value)) FROM Word
Maybe something similar to
prisma.word.aggregate({
_avg: { value: { length: true } }
});
Nurul
08/16/2022, 9:13 AMNurul
08/16/2022, 9:13 AMRain
08/14/2022, 7:13 PMset: []
to disconnect all related records.
Will this work ?
prisma.user.create({
data: {
name: 'test',
likes: {
set: [],
connect: [{ name: 'a'}, {name: 'b'}]
}
});
Christoffer
08/14/2022, 8:10 PMmodel AuthProvider {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
type AuthProviderType
externalUserId String? @unique
email String @unique // this should not be unique if the userId is the same among two AuthProviders
emailVerified Boolean? @default(false)
password String? // Hashed password
user User @relation(fields: [userId], references: [id])
userId String
@@map("auth_providers")
}
A user can have many authentication providers, such as email + password, google, twitter... that they can use to sign in with
Now here comes the tricky part:
what I want to accomplish is to make it so an AuthProviders email is unique, but ONLY if the userId of that AuthProvider is different.
So a user should be able to have several AuthProviders with the same email, but if one user tries to connect an authprovider with an email that another user already has connected (on any of their authproviders), then it should fail via unique constraint.
would this be achieveable just using uniuqe constraints/indexes in the schema?nick
08/14/2022, 9:19 PMnick
08/14/2022, 9:19 PMnick
08/14/2022, 9:51 PMinclude: { posts: true}
on a user query but I only want the first post in the returned posts array, any way to do this?Doron Roberts-Kedes
08/14/2022, 11:37 PMAladin
08/14/2022, 11:53 PMprisma.$use(someMiddlewareWithAccessToRequest)
• Process the request
• prisma.$unuse(someMiddlewareWithAccessToRequest)
• Return the response
This will allow people to define context and request aware middlewareSamrith Shankar
08/15/2022, 4:28 AMPRISMA_QUERY_ENGINE_LIBRARY=/opt
And when I
ls /opt
I get the following output:
libquery_engine-rhel-openssl-1.0.x.so.node
But when I run the lambda I still get error:
"Runtime.UnhandledPromiseRejection: Error: Query engine library for current platform \"linux-arm64-openssl-1.0.x\" could not be found.",
"You incorrectly pinned it to linux-arm64-openssl-1.0.x",
"",
"This probably happens, because you built Prisma Client on a different platform.",
"(Prisma Client looked in \"/var/task/src/libquery_engine-linux-arm64-openssl-1.0.x.so.node\")",
"",
"Searched Locations:",
"",
" /.prisma/client",
" /var/task",
" /var/task/src",
" /var/task/src",
" /tmp/prisma-engines",
" /var/task/src",
"",
"You already added the platforms \"darwin\", \"linux-arm64-openssl-1.0.x\" to the \"generator\" block",
"in the \"schema.prisma\" file as described in <https://pris.ly/d/client-generator>,",
"but something went wrong. That's suboptimal.",
"",
"Please create an issue at <https://github.com/prisma/prisma/issues/new>",
" at process.<anonymous> (file:///var/runtime/index.mjs:775:15)",
" at process.emit (node:events:527:28)",
" at emit (node:internal/process/promises:140:20)",
" at processPromiseRejections (node:internal/process/promises:274:27)",
" at processTicksAndRejections (node:internal/process/task_queues:97:32)"
Any idea what am I missing?
EDIT: Switching engine type to binary
and uploading the binary, worked!Oleksii
08/15/2022, 6:42 AMSlackbot
08/15/2022, 6:53 AMAdrien Wald
08/15/2022, 10:05 AMprisma
instance made available in the callback or can you use the prisma
instance on which you called $transaction
?Shamim Fahad
08/15/2022, 10:54 AMError: P3006
Migration 20220815103305_product_and_order_incremental_id
failed to apply cleanly to the shadow database.
Error:
db error: ERROR: value type string doesn't match type int of column "id"
HINT: you will need to rewrite or cast the expression
0: sql_migration_connector::validate_migrations
at migration-engine/connectors/sql-migration-connector/src/lib.rs:270
1: migration_core:state:DevDiagnostic
at migration-engine/core/src/state.rs:250
can anyone help me about what I should do?Shamim Fahad
08/15/2022, 10:55 AMRichard
08/15/2022, 1:51 PMGeebrox
08/15/2022, 2:29 PMInvalid `prisma.user.upsert()` invocation:
Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: RawDatabaseError { code: "unknown", message: "Command failed (WriteConflict): WriteConflict error: this operation conflicted with another operation. Please retry your operation or multi-document transaction.)" } })
What does it mean?Fishie
08/15/2022, 3:17 PMOleksii
08/15/2022, 4:59 PMDoron Roberts-Kedes
08/15/2022, 5:11 PMasync_hooks
? Follow up question - can it be circumvented?
I'm assuming the answer to the second question is "no". The reason I'm asking is because I'm attempting to migrate my app off of Meteor by incrementally adopting Prisma to replace Meteor collections. Meteor, unfortunately, uses fibers and can lead to memory leaks when used with async_hooks
. We could move forward with one massive commit that introduces Prisma and removes Meteor, but incremental adoption would be preferable. Incremental adoption poses the problem of adding async_hooks
into a Meteor environment, which leads to my questions above.
Thanks!Aman
08/15/2022, 7:37 PMmodel User {
id Int @id @default(autoincrement())
auth0Id String? @unique
authEmail String? @unique
email String @unique
name String?
companyData CompanyData?
}
model CompanyData {
id Int @id @default(autoincrement())
owner User @relation(fields: [ownerId], references: [id])
ownerId Int @unique
capTable CapTable?
}
model CapTable {
id Int @id @default(autoincrement())
stakeholder Stakeholder[]
stockClass StockClass[]
vestingTerm VestingTerm[]
transactions Transactions[]
companyData CompanyData @relation(fields: [companyId], references: [id])
companyId Int @unique
}
model ConvertibleTransactions {
id Int @default(autoincrement()) @unique
json Json?
transactions Transactions?
}
model SecurityTransactions {
id Int @default(autoincrement()) @unique
json Json?
transactions Transactions?
}
model WarrantsTransactions {
id Int @default(autoincrement()) @unique
json Json?
transactions Transactions?
}
model Transactions {
id Int @default(autoincrement()) @unique
convertibleTransactions ConvertibleTransactions? @relation(fields: [convertibleTransactionId], references: [id])
convertibleTransactionId Int @unique
securityTransactions SecurityTransactions? @relation(fields: [securityTransactionId], references: [id])
securityTransactionId Int @unique
warrantsTransactions WarrantsTransactions? @relation(fields: [warrantsTransactionId], references: [id])
warrantsTransactionId Int @unique
capTable CapTable? @relation(fields: [capTableId], references: [id], onDelete: Cascade)
capTableId Int?
}
and this is my prisma query
await prisma.user.update({
where: {
id: userData.id,
},
data: {
companyData: {
update: {
capTable: {
update: {
transactions: {
update: {
convertibleTransactions: {
upsert: {
create: {
json: data,
},
update: {
json: data,
},
where: {
id: data?.id || -1,
},
},
},
// where: {
// convertibleTransactionId: data.convertibleId || -1,
// },
},
},
},
},
},
},
}, ,
});
can someone help me with what I am doing wrong hereTed Joe
08/15/2022, 7:39 PMyarn rw prisma migrate deploy
, I get an error saying:
1 migration found in prisma/migrations
Error: P3005
The database schema is not empty. Read more about how to baseline an existing production database: <https://pris.ly/d/migrate-baseline>
What am I doing wrong and how can I fix it?Italo Gama
08/15/2022, 10:39 PMItalo Gama
08/15/2022, 10:39 PMItalo Gama
08/15/2022, 10:40 PMItalo Gama
08/15/2022, 10:40 PMItalo Gama
08/15/2022, 10:41 PM