Arun Kumar
06/09/2021, 7:49 AMArun Kumar
06/09/2021, 7:50 AMDaniel Laera
06/09/2021, 7:51 AMyarn dev
…Arun Kumar
06/09/2021, 7:51 AMArun Kumar
06/09/2021, 7:52 AMYash Rathore
06/09/2021, 7:57 AMmodel ChartSection {
id Int @id @default(autoincrement())
backgroundColor String
tickColor String
charts Chart[]
}
model Chart {
data ChartData[]
}
model ChartData {
...
}
Vladi Stevanovic
Daniel Laera
06/09/2021, 8:03 AMDavedavedave
06/09/2021, 8:27 AMconst PriceService = await prisma.priceService.createMany({
data: [ ... ],
skipDuplicates: true,
})
"Property 'createMany' does not exist on type 'PriceServiceDelegate<RejectOnNotFound | RejectPerOperation>'."
and its true, when i looked into the delegate, it has create, upsert etc, but createMany is missing.
typescript version is 4.3 (editor uses correct one)
Is this a library issue? Best regards, DavidJulian
06/09/2021, 11:11 AMpassword
is removed and replaced with hashedPassword
, a nested profile
is created and inside profile an address
is created?
{
"email": "<mailto:test@test.nl|test@test.nl>",
"password": "abcd",
"profile": {
"firstName": "Test",
"lastName": "T",
"address": {
"street": "A",
"zipcode": "B",
"city": "C",
"state": "D",
"country": "E"
}
}
}
Because it seems like a bit of a pain to manually map every field to an object that can be used for a create
query functionJulian
06/09/2021, 11:55 AMDev__
06/09/2021, 12:51 PMSET NULL
inside the schema.prisma? Is the only way of doing this an optional relation?Eddy Nguyen
06/09/2021, 1:02 PMJulian
06/09/2021, 2:55 PMPrimsa.UserDelegate
for my User model, it says it requires <_GlobalRejectSettings_>
Where do I grab that from?Julian
06/09/2021, 2:56 PMGeneric type 'UserDelegate<GlobalRejectSettings>' requires 1 type argument(s)
nenadv
06/09/2021, 3:39 PMif (!userId) {
return;
}
let newUser;
const checkIfNewUserMigration = await prismaClient.user.findFirst({
where: {
systemId: userId,
},
select: {
systemId: true,
id: true,
},
});
if (!checkIfNewUserMigration) {
newUser = await prismaClient.user.create({
data: {
systemId: userId,
firstName: firstName,
lastName: lastName,
avatar: avatar,
conversationMemberships: {
create: {
conversation: { connect: { id: conversation.id } },
},
},
},
select: {
id: true,
systemId: true,
},
});
} else {
newUser = checkIfNewUserMigration;
}
produce this error
throw new import_engine_core.PrismaClientKnownRequestError(message, e.code, this.prisma._clientVersion, e.meta);
^
Error:
Invalid `prisma.user.create()` invocation:
Unique constraint failed on the constraint: `systemId_unique`
?
There are explicit checks in the code to avoid this as you can see. Can also provide schema etc. if needed?
Also do add, on the sample batch data I'm testing this it randomly breaks, so it isn't specific data which causes the issues, sometimes it is the 100. entry, sometimes 130.migz
06/09/2021, 3:50 PMconnectOrCreate
on an array? similar to this, but instead creating the record if it doesn't exist
data: {
email: '<mailto:vlad@prisma.io|vlad@prisma.io>',
posts: {
connect: [{ id: 8 }, { id: 9 }, { id: 10 }],
},
},
Brandon Leichty
06/09/2021, 4:46 PMuserId
of the currently logged in user matches the quoteId
that the user is looking to update/delete.
This is what I'm currently doing (and it works). But I'm wondering if there's a way I can do this without multiple calls to the database? Would be great if I could do something like prisma.update({ where: {id AND userId}})
👈 pseudocode.
editQuote: async (_, { ...input }, context) => {
const { prisma, user } = context;
const { id, quote, author, categories, favorite } = input;
const originalQuote = await prisma.quote.findUnique({
where: { id },
});
// Check to see if the logged in user owns this quote before updating
if (user == originalQuote.userId) {
const editedQuote = await prisma.quote
.update({
where: {
id: id,
},
data: {
quote,
author,
},
})
.catch((e) => {
throw e;
});
return editedQuote;
} else {
console.log("You are not authorized to edit this quote");
return null;
}
},
Juan Varela
06/09/2021, 5:31 PMTo return custom error messages to your client, you can return error instead of throwing it.The problem is that when using nexus.js with typescript, the resolver doesn’t allow to return an error. Other than returning:
return new Error("Custom error") as any
What can I do if I have something like this:
export default mutationField('signup', {
type: AuthPayload, // Here should be OR ERROR
async resolve(_parent, args, context: Context) {
Thank you very much in advance!jasci
06/09/2021, 6:54 PMcontext.prisma.someModel.findUnique({ where: { id: someId } }).someField()
2.
(await context.prisma.someModel.findUnique({ where: { id: someId } })).someField
When I use await
it seems like I don’t get access to the relation fields. In the second example if the field is virtual(some relation) it won’t be available, why is that ?
But if I use the example #1 I am able to somehow call the field and resolve its value. How does it work ?
How to properly retrieve fields of a particular model ?
Maybe some links to the doc?
Thank you.David
06/09/2021, 7:07 PMbrettski
06/09/2021, 8:26 PMHalvor
06/09/2021, 8:43 PMHalvor
06/09/2021, 8:46 PMHalvor
06/09/2021, 8:46 PMbrettski
06/09/2021, 9:29 PM@prisma/client
and prisma
Installation is done using npm i --production
version 2.22.1
seems okay
when I try 2.24.1
I aways end up with Error: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.
rolling back to 2.22.1
and all is okay again. No other changes.
Is there anything in versions > 2.22.1 which may be causing this in this scenario? I looked through the release notes and nothing stuck out.Albert Gao
06/10/2021, 3:08 AMopen
high
low
are prices, volume
are big numbers (BigInt?) I am using PostgreSQL 🙂
i can save as all string and parse at run time, but just want to have more precise data type so maybe i need to query the price in the future, just in case
ThanksKent C. Dodds
06/10/2021, 3:13 AMSamrith Shankar
06/10/2021, 5:27 AMEGOIST
06/10/2021, 6:28 AM