Prisma (ORM) - get the index value of inserted row

Viewed 170

I'm trying to use Prisma (ORM) to manage my MySQL database.

When I used MySQL directly I could run mysql_insert_id() after insert command to get the auto_increment indexes values I've just inserted.

How can I achieve this in Prisma? The return value of insert is the affected rows, not the indexes.

EDIT

If you use the prisma.create() it does return the object with it's new id.

But if you use prisma.createMany() it return only the count of affected rows ?!?!

Someone care to explain the design behind this?

1 Answers

You would need to use Raw Query to execute the insert statement which returns indexes values.

From the documentation:

Use $queryRaw to return actual records.

Use $executeRaw to return a count of affected rows

So you would need to use the queryRaw method.

Related