next-admin icon indicating copy to clipboard operation
next-admin copied to clipboard

[FEATURE] - Make Next-Admin ORM agnostic

Open foyarash opened this issue 4 months ago • 0 comments

Summary

Currently, Next-Admin is made to work only with Prisma. This is limiting for users that uses other ORMs such as Drizzle, and more largely query libraries like knex, or even more low level libs like pg.

Now that we are able to use the lib without depending on the Prisma DMMF, we should be able to abstract the CRUD queries that are made on the server and extract the Prisma logic in its own adapter.

  • [ ] Create a generator for Drizzle
  • [ ] Create a helper function for other kind of generators to generate schemas in the right file
  • [ ] Create a type generator that would either use Prisma or Drizzle types
  • [ ] Create an adapter logic
  • [ ] Create Prisma and Drizzle adapters

Basic Example

const adapter = new PrismaAdapter(prismaInstance)

const { run } = createHandler({
  apiBasePath: "/api/admin",
  options,
  adapter,
});

export { run as DELETE, run as GET, run as POST };

foyarash avatar Oct 03 '24 15:10 foyarash