How can I use plain object instead of composite types ?
Hi,
We were using Prisma v4.10.0 in ou project and we upgraded to 4.16.0 in order to use the new $extends() features
Problem :
When we updated to 4.16, all of our code broke because now, our mongo's embedded documents are defined as "composite types" with the following struct :
{ objects : {}, scalars: {}, composites: {} }
It's a huge pain because before we had the plain object directly and we could do something like :
const user = await prisma.user.find();
console.log(user.profile.name)
now :
const user = await prisma.user.find();
console.log(user.profile.scalars.name)
Any idea if there is an option to go back to old way ?2 Replies
Hi :vmathi: Sorry to hear that! You can try to upgrade to a fixed version,
v4.16.2-dev.2
, which should fix some issues with composites:
Another option is to try to have explicit type selection by explicitly select the fields you need in your queries:
You can also use Prisma's $extends
feature to create custom extensions that simplify access to your nested fields, allowing you to define getter methods to access fields directly without navigating through scalars
:
The latest option i would suggest would be to downgrade to v4.15.0
if none of the options above workSolution
ty !
just checked and the composites disapeared on v5