Adam
10/19/2021, 8:48 PMprisma.role.create({
data: {
Id: 1,
Name: 'Test',
Description: 'Test',
IsActive: true,
CreatedByUser: { connect: { Id: 2 } },
LastUpdateByUser: { connect: { Id: 2 } },
},
});
and PrismaClient doesn’t allow me to, because of:
Types of property 'Id' are incompatible. Type 'number' is not assignable to type 'never'.`
and hinting me about:
The expected type comes from property 'data' which is declared here on type '{ select?: RoleSelect; include?: RoleInclude; data: (Without<RoleCreateInput, RoleUncheckedCreateInput> & RoleUncheckedCreateInput) | (Without<...> & RoleCreateInput); }'
and my question is - why PrismaClient doesn’t allow me to use Id for creating?
in my model schema I have simply:
Id Int @id @default(autoincrement())
Similar result I have with upsert as well. And what is totally weird to me - some models works fine. I already spend 2 hours to figure out why it happens to this particular model. Can anyone help?Matt Knight
10/19/2021, 9:23 PMexistingListing: Listings & {
ListingPhotos: ListingPhotos[];
}
How do I instantiate (if that is the right word?) it on the client?
Normally I would do something like this:
existingListing: Listings = []
But with the nested model, it doesn't work.Matt Knight
10/19/2021, 9:40 PMany
)Jordan Epps
10/21/2021, 9:48 PM$transaction
is incorrect? I submitted an issue today.Taylor Preston
10/23/2021, 7:45 PMaccount_number
on a user unless I specifically ask for it.Mischa
10/27/2021, 11:01 AMupsert()
calls. is this correct?
created an issue: https://github.com/prisma/prisma/issues/9972Mischa
10/27/2021, 11:16 AMTigran Tokmajyan
10/27/2021, 4:25 PMWARNING in ./libs/prisma/src/lib/client/runtime/index.js 81:73-80
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
WARNING in ./libs/prisma/src/lib/client/runtime/index.js 85:15-22
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
Debugger listening on <ws://localhost:59074/bf3dd720-b8d2-4f0e-91c1-d9b4532054a3>
Debugger listening on <ws://localhost:59075/bf3dd720-b8d2-4f0e-91c1-d9b4532054a3>
For help, see: <https://nodejs.org/en/docs/inspector>
C:\gits\boon\backend\dist\apps\cron\webpack:\libs\prisma\src\lib\client\runtime sync:2
var e = new Error("Cannot find module '" + req + "'");
^
Error: Cannot find module 'os'
at webpackEmptyContext (C:\gits\boon\backend\dist\apps\cron\webpack:\libs\prisma\src\lib\client\runtime sync:2:1)
at ../../node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js (C:\gits\boon\backend\dist\apps\cron\webpack:\libs\prisma\src\lib\client\runtime\index.js:1740:15)
at __require2 (C:\gits\boon\backend\dist\apps\cron\webpack:\libs\prisma\src\lib\client\runtime\index.js:89:45)
at ../../node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/index.js (C:\gits\boon\backend\dist\apps\cron\webpack:\libs\prisma\src\lib\client\runtime\index.js:2004:56)
at __require2 (C:\gits\boon\backend\dist\apps\cron\webpack:\libs\prisma\src\lib\client\runtime\index.js:89:45)
at Object../libs/prisma/src/lib/client/runtime/index.js (C:\gits\boon\backend\dist\apps\cron\webpack:\libs\prisma\src\lib\client\runtime\index.js:30779:33)
at __webpack_require__ (C:\gits\boon\backend\dist\apps\cron\webpack:\webpack\bootstrap:19:1)
at Object../libs/prisma/src/lib/client/index.js (C:\gits\boon\backend\dist\apps\cron\webpack:\libs\prisma\src\lib\client\index.js:17:5)
at __webpack_require__ (C:\gits\boon\backend\dist\apps\cron\webpack:\webpack\bootstrap:19:1)
at Object../libs/common/src/lib/services/prisma.service.ts (C:\gits\boon\backend\dist\apps\cron\webpack:\libs\common\src\lib\services\prisma.service.ts:2:1)
Devin
10/28/2021, 4:08 AMconst projects = ["project 1", "project 2"]
projects.forEach(async (p) => await db.project.create({data: {name: p}})
const dbProjects = db.project.findMany()
db.task.create({
data: {
name: 'some task',
project: {connect: {id: dbProject.find((p) => p.name.includes("project 1")).id},
I’m getting TS errors with dbProject.find
because of course it could be undefined… Is there a better way to be thinking about this?Salvador Lopez Mendoza
10/28/2021, 5:15 PMin
in the where clause of a query where the column data type is a string
which values are like 1,2
? Like prisma.model.findMany({ where: { col: { in: [1, 2] } } })
Jarid Margolin
10/29/2021, 10:56 PMNavin
10/31/2021, 4:14 PMsven
11/02/2021, 9:55 AMArgument started: Got invalid value '2021' on [...]. Provided String, expected DateTime or NullableDateTimeFieldUpdateOperationsInput or Null.
Is it possible to save say ‘2021’ in a date field and then also query it?Tyler Bell
11/03/2021, 3:48 AMPlease note that it is not possible at the moment to have a null-cursor, or a cursor and orderBy combination that not stable (unique).
In my case, the cursor is not null, so assuming it’s from “a cursor and orderBy combination”
My query is…
prisma.member.count({
where: {
app: { id }
},
orderBy: {
createdAt: "desc"
},
cursor: {
id: after_cursor
}
})
potatoxchip
11/03/2021, 5:56 PMINSERT IGNORE INTO ... ;
?Mischa
11/03/2021, 6:15 PMNick Zhang
11/04/2021, 6:53 AMYaakov
11/05/2021, 2:36 PMGheorghe
11/05/2021, 4:47 PMYaakov
11/08/2021, 3:23 PMmodel User {
id Int @id @default(autoincrement())
name String
posts Post[]
}
model Post {
id Int @id @default(autoincrement())
author User? @relation(fields: [authorId], references: [id])
authorId Int?
}
Example #1
Filters out all Posts with a null authorId
if req.query.authorName
is `undefined`:
router.get('/posts', async (req, res, next) => {
const posts = await prisma.post.findMany({
where: {
author: {
is: {
name: {
in: req.query.authorName
}
}
}
},
include: {
author: true
}
});
res.json({ data: posts });
});
Example #2
If req.query.authorId
is undefined
, it does not filter and returns everything:
router.get('/posts', async (req, res, next) => {
const posts = await prisma.post.findMany({
where: {
authorId: {
in: req.query.authorId
}
},
include: {
author: true
}
});
res.json({ data: posts });
});
Why is there inconsistent behavior between the 2 examples?
In example #1, how can I assure that no filter is performed when req.query.authorName
is undefined
?Mischa
11/08/2021, 3:56 PMvalidateUpsertLinkedIn(args: PrismaTypes.CandidateUpsertArgs) {
return Prisma.validator<PrismaTypes.CandidateUpsertArgs>()(args)
}
packages/repo/src/repository/candidate.ts:22:12 - error TS2615: Type of property 'AND' circularly references itself in mapped type '{ [K in keyof CandidateCommentScalarWhereInput]: K extends keyof CandidateCommentScalarWhereInput ? Exact<CandidateCommentScalarWhereInput[K], CandidateCommentScalarWhereInput[K]> : CandidateCommentScalarWhereInput[K]; }'.
Mischa
11/09/2021, 3:21 PMBen Ezard
11/12/2021, 11:42 PMmodel Author {
name String
}
model Book {
author Author?
}
const book = await this.prismaService.book.create({
include: {
author: true,
},
data: {
author: {
create: {
name: 'Bob',
},
},
},
})
In the above example, book.author
is nullable, yet that the fact that that function succeeded and is returning data means that that field will never be null
Is there an existing way to get book.author
back as a non-nullable value, or should I create a feature request on GitHub for this?Benjamin Smith
11/13/2021, 10:04 PMBenjamin Smith
11/13/2021, 11:30 PMAlternatively you can define any Npm package that follows our generator specificationBut I've looked through all of the docs and can't find this generator specification.
Pinja Jäkkö
11/17/2021, 12:13 PMTSError: ⨯ Unable to compile TypeScript:
src/controllers/charts/discussions.ts:61:26 - error TS2694: Namespace '"[...]/node_modules/.prisma/client/index".Prisma' has no exported member 'validator'.
61 const messages: Prisma.validator<Prisma.discussionInclude>()({
Hi, I'm trying to use the validator for the first time but am getting this error.Mike Willbanks
11/22/2021, 6:54 PMawait prisma.model.update({
where: {
model_id: {
not: +model.model_id,
},
},
data: {
is_archived: true
},
});
errorInvalid `prisma.model.update()` invocation:{where: {model_id: {not: 7}~~~~~~~~},data: {is_archived: true}}Argument model_id: Got invalid value{not: 7}on prisma.updateOnemodel. Provided Json, expected Int
Devin
11/23/2021, 6:03 PMprisma.piranhas.findMany({
select: {
name as blipbleepblop
}
})
Italo Gama
11/27/2021, 1:48 AMWingy
11/27/2021, 5:53 AMGalaxyInfo.prisma.$executeRaw`
CREATE TEMPORARY VIEW "Kill_temp" AS
SELECT *
FROM "Kill_clean"
WHERE
killer_id IN (${Prisma.join(players)})
`,
Your raw query had an incorrect number of parameters. Expected: `0`, actual: `1`.
Anyone know why I'm getting this? trying to create a temp view with a dynamic where for the rest of my transaction to use