Active Record-like interface to Prisma result objects
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 47.6k
- Forks
- 2.5k
- Avg merge
- 21h 59m
- Merged PRs (30d)
- 95
Description
Problem
Currently prisma does not support Active Record-like interface by default & we need to do the following or we can define client extensions ( but we need to define the instance methods for each model which is not productive in my opinion)
const user = await prisma.user.findFirst({
where: { email: "test@example.com" }
});
await prisma.user.update({
where: { id: user.id },
data: { email: "updated@example.com" }
})
Suggested solution
It would be great if we get the active-record like interface by default.
const user = await prisma.user.findFirst({
where: { email: "test@example.com" }
});
user.email = "updated@example.com";
await user.save();
await user.delete();
Alternatives
NULL
Additional context
NULL
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading Prisma Client extensions and the Prisma result-object flow illustrated with prisma.user.findFirst, update, and the proposed save/delete calls. Define the scope for model instances returned by queries, then verify that field mutation, save, and delete work consistently across models and supported database connectors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- backend-api-design, databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100