I am using prisma with mongoDb for the first time and I want to update a boolean value stored in a collection, but I am not able to find a way/query to update the value from true to false or vise versa…:(
const updateUser = await prisma.user.update({
where: {
userToken: token,
},
data: {
isOnline: true,
},
})
I have this ‘isOnline’ stored as false default and this is what I have tried wrt prisma official documentation, but this did not worked for me
2
Answers
I think you are looking for
set
Since
true
andfalse
values could be mistaken as a special instruction in "prisma logics", the response from @Fastnligth should be the correct one -did’t tried that though-.Since Prisma ORM implemented MongoDB as an after thought, some of these functionalities might "seem a bit off".
I’ve arrived here trying to update an embedded field without updating the whole document, just the given field.
Leaving my two cents in case somebody else is having the same sailing over google ⛵️
You can do that as follows
official docs: https://www.prisma.io/docs/concepts/components/prisma-client/composite-types