You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi 👋
First of all, thank you very much for your work. After your answer, we decided to use your lib on our on production application and it saved us a lot of time!
Describe the bug
As mentioned in the documentation, I create a UserProfile which has a relation with the table User. When I use the factory to create a UserProfile, the return object is not similar to one from the DB so I can't call my relation like userProfile.user.
To Reproduce
Create a relation like this:
export const UserProfileFactory = defineUserProfileFactory({
defaultData: () => ({
id: chance.guid(), // chance is a lib similar to faker
firstName: chance.first(),
user: UserFactory,
}),
});
In my test, I do : const recipientProfile = await UserProfileFactory.create();.
My recipientProfile doesn't have a user property but a userId which means if I want to do recipientProfile.user I can't and I have to do a prisma call to get my User db object.
Expected behavior
My factory returns a DB object and so I can easily use my relation through my new created object.
Your Schema
model User {
id String @id @default(dbgenerated("uuid_generate_v4()")) @db.Uuid
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
email String @unique
userProfiles UserProfile[]
}
model UserProfile {
id String @id @default(dbgenerated("uuid_generate_v4()")) @db.Uuid
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
userId String @db.Uuid
user User @relation(fields: [userId], references: [id])
firstName String?
}
Environment (please complete the following information):
Database kind: PostgreSQL
Node.js version: 18.14.6
@prisma/client version: 4.13.0
TypeScript version: 5.0.4
Thanks again for your hard work!
The text was updated successfully, but these errors were encountered:
Echoing the appreciation expressed by @adrijere! This is a very useful extension for Prisma, and the former FactorbyBot user in me feels right at home!
I recently deployed Fabbrica in my codebase, and a co-worker was wanting the same feature described here. I don't have time to submit a PR, but wanted to add my voice the group of folks requesting the feature.
Hi 👋
First of all, thank you very much for your work. After your answer, we decided to use your lib on our on production application and it saved us a lot of time!
Describe the bug
As mentioned in the documentation, I create a
UserProfile
which has a relation with the tableUser
. When I use the factory to create aUserProfile
, the return object is not similar to one from the DB so I can't call my relation likeuserProfile.user
.To Reproduce
Create a relation like this:
In my test, I do :
const recipientProfile = await UserProfileFactory.create();
.My
recipientProfile
doesn't have auser
property but auserId
which means if I want to dorecipientProfile.user
I can't and I have to do a prisma call to get myUser
db object.Expected behavior
My factory returns a DB object and so I can easily use my relation through my new created object.
Your Schema
Environment (please complete the following information):
@prisma/client
version: 4.13.0Thanks again for your hard work!
The text was updated successfully, but these errors were encountered: