prisma chobo
07/20/2021, 8:57 PMconst transaction = prisma.transaction.create({
data: {
audience,
description,
paymentMethodId: '',
type: 'TRANSFER',
balances: {
create: [
{
amount,
accountId: payeeId,
currency: 'GPT',
},
{
amount: amount * -1,
accountId: payorId,
currency: 'GPT',
},
],
},
transfer: {
create: {
payeeId,
payorId,
},
},
accounts: {
connect: [
{
id: '',
},
{
id: '',
},
],
},
},
});
And this is my schema for transaction and account:
model Transaction {
accounts Account[]
}
model Account {
transactions Transaction[]
}
This is my error:
Type '{ audience: AUDIENCE; description: string; paymentMethodId: string; type: "TRANSFER"; balances: { create: { amount: number; accountId: string; currency: "GPT"; }[]; }; transfer: { create: { ...; }; }; accounts: { ...; }; }' is not assignable to type '(Without<TransactionCreateInput, TransactionUncheckedCreateInput> & TransactionUncheckedCreateInput) | (Without<...> & TransactionCreateInput)'.
Type '{ audience: AUDIENCE; description: string; paymentMethodId: string; type: "TRANSFER"; balances: { create: { amount: number; accountId: string; currency: "GPT"; }[]; }; transfer: { create: { ...; }; }; accounts: { ...; }; }' is not assignable to type 'Without<TransactionUncheckedCreateInput, TransactionCreateInput> & TransactionCreateInput'.
Type '{ audience: AUDIENCE; description: string; paymentMethodId: string; type: "TRANSFER"; balances: { create: { amount: number; accountId: string; currency: "GPT"; }[]; }; transfer: { create: { ...; }; }; accounts: { ...; }; }' is not assignable to type 'Without<TransactionUncheckedCreateInput, TransactionCreateInput>'.
Types of property 'paymentMethodId' are incompatible.
Type 'string' is not assignable to type 'undefined'.
Code Coffee
07/21/2021, 3:13 AMprisma chobo
07/21/2021, 4:35 AMCode Coffee
07/21/2021, 5:19 PMRyan
07/22/2021, 5:37 AMCode Coffee
07/22/2021, 5:57 AMexplicit many to many
example here: https://www.prisma.io/docs/support/help-articles/working-with-many-to-many-relations
It says it would be a create to the PostTags
but the example does a create to post
Ryan
07/22/2021, 6:03 AMPostTags
and also the Tag
table.
The tags: { create: [] }
does this.Code Coffee
07/22/2021, 6:05 AMCode Coffee
07/22/2021, 6:05 AMCode Coffee
07/22/2021, 6:07 AMCode Coffee
07/22/2021, 6:08 AMRyan
07/22/2021, 6:08 AMRyan
07/22/2021, 6:09 AMCode Coffee
07/22/2021, 6:15 AMpost.create
and the tags: { create: [] }
is what is considered querying the relation model? And in no situation do we ever do a PostTags.create
?Code Coffee
07/22/2021, 6:15 AMRyan
07/22/2021, 6:19 AMPostTags.create
. Tags can be created connected via Post
when your can create them.Code Coffee
07/22/2021, 6:26 AMprisma chobo
07/22/2021, 3:29 PMmodel Account {
id String @id @default(cuid())
type ACCOUNT_TYPE @default(PERSONAL)
userId String? @map("user")
username String @unique
// *************** RELATIONS *****************
balances Balance[]
collections Transfer[] @relation("Collections")
followers Account[] @relation("AccountFollows", references: [id])
following Account[] @relation("AccountFollows", references: [id])
funds Fund[]
payments Transfer[] @relation("Payments")
paymentMethods PaymentMethod[]
payouts Payout[]
profile Profile?
transactions Transaction[]
user User? @relation(fields: [userId], references: [id])
// *******************************************
createdAt DateTime @default(now())
updatedAt DateTime @default(now())
deletedAt DateTime?
}
model Transaction {
id String @id @default(cuid())
audience AUDIENCE @default(PRIVATE)
description String
exchangeRate Float?
status TRANSACTION_STATUS @default(PENDING)
type TRANSACTION_TYPE
// *************** RELATIONS *****************
accounts Account[]
balances Balance[]
fund Fund?
fees Fee[]
payout Payout?
transfer Transfer?
// *******************************************
createdAt DateTime @default(now())
updatedAt DateTime @default(now())
deletedAt DateTime?
}
Ryan
07/23/2021, 6:48 AM