Josh Williams
11/28/2020, 3:55 AMtylim
11/28/2020, 6:02 PMtylim
11/28/2020, 6:02 PMexport const seedUser = mutationField('seedUser', {
type: 'User',
args: {
number: intArg(),
},
resolve: (_, { number }, { prisma }) => {
return [...new Array(number)].map(() =>
prisma.user.create({
data: {
userId: Math.random().toString(),
email: Math.random().toString(),
profile: {
create: { bio: '123', name: '456' },
},
},
})
)
},
})
tylim
11/28/2020, 6:03 PMMatthew Eman
11/28/2020, 8:31 PMyarn prisma init
(or any command really) im getting the following error message:
Failed to get the definition file
Error: couldn't find 'prisma.yml' file. Are you in the right directory?
Matthew Eman
11/28/2020, 8:34 PMJosh Williams
11/28/2020, 11:24 PMJosh Williams
11/28/2020, 11:25 PMNafis Shah
11/29/2020, 1:45 AMtylim
11/29/2020, 12:33 PMtylim
11/29/2020, 7:07 PMArmaan Dhanji
11/30/2020, 6:55 AMtylim
11/30/2020, 10:53 AMmodel User {
id String @id
email String? @unique
profile Profile?
product Product[]
role ROLE @default(USER)
orders Order[]
}
model Order {
id Int @id @default(autoincrement())
buyerId String
buyer User @relation(fields: [buyerId], references: [id])
status ORDER_STATUS
seller User @relation(fields: [sellerId], references: [id])
}
User can be seller or buyer
however this is giving me errortylim
11/30/2020, 10:54 AMtylim
11/30/2020, 10:55 AMtylim
11/30/2020, 10:56 AMtylim
11/30/2020, 10:56 AMmodel User {
id String @id
email String? @unique
profile Profile?
product Product[]
role ROLE @default(USER)
orders Order[]
sales Sale[]
}
model Order {
id Int @id @default(autoincrement())
buyerId String
buyer User @relation(fields: [buyerId], references: [id])
status ORDER_STATUS
}
model Sale {
id Int @id @default(autoincrement())
sellerId String
seller User @relation(fields: [sellerId], references: [id])
status SALES_STATUS
}
Natalia
KJReactor
11/30/2020, 9:42 PMA
and connect to an existing record of entity B
using B.id
in the connect
field ? the following is not working for me. The relationship is 1:1 so B.id
should be valid as a unique key for connect
, no?
prisma.A.create({
data: {
...,
B: { connect: { id: ... } }
}
})
Dustin
12/01/2020, 1:41 AMconst findUnique = await this.prisma.availability.findUnique({
where: {
propertyId_date_status: {
propertyId: 'cki4d4rn102310qqlri351ppf',
status: AvailabilityStatus.AVAILABLE,
date: new Date('2020-12-02T00:00:00.000Z'),
}
}
});
const findFirst = await this.prisma.availability.findFirst({
where: {
propertyId: 'cki4d4rn102310qqlri351ppf',
status: AvailabilityStatus.AVAILABLE,
date: new Date('2020-12-02T00:00:00.000Z'),
}
});
console.log(findUnique); // <-- Null
console.log(findFirst); // <-- Not null
model Availability {
date DateTime
property Property @relation(fields: [propertyId], references: [id])
propertyId String
status AvailabilityStatus @default(AVAILABLE)
@@unique([propertyId, date, status])
}
enum AvailabilityStatus {
AVAILABLE
}
raghib shahriyer
12/01/2020, 7:27 AMBruno Casado
12/01/2020, 3:24 PMBruno Casado
12/01/2020, 3:28 PMJin
12/01/2020, 4:14 PMJoe Graham
12/01/2020, 7:50 PMitems
and item_versions
(*note: sql server)
create table items {
id int IDENTITY(1,1) constraint items_pkey primary key,
version int not null
}
create table item_versions {
id int IDENTITY(1,1) constraint item_versions_pkey primary key,
item_id int not null,
version int not null,
name nvarchar(15) not null
}
so in the above example i have a 1:* items -> item_versions but I also want to model 1:1 item_versions -> items, how would i model that in my prisma schema?
and what keys would i need to define on the tables to have prisma be able to query that relationship?Joe Graham
12/01/2020, 7:58 PMtylim
12/02/2020, 12:40 AMEddy Nguyen
12/02/2020, 12:20 PMbinaryTargets
. Does anyone knows how to fix this?
( I can still generate, migrate, etc. so I think it’s an extension issue..?)tylim
12/02/2020, 5:33 PM