mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-25 06:14:59 +00:00
feat: implement DBAL adapter with Prisma; add closeAdapter and getAdapter functions
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useState } from 'react'
|
||||
import { useState, type ComponentType } from 'react'
|
||||
import { Box, Card, InputAdornment, Stack, TextField, Typography } from '@mui/material'
|
||||
import type { SvgIconProps } from '@mui/material'
|
||||
import CropFreeIcon from '@mui/icons-material/CropFree'
|
||||
@@ -26,7 +26,7 @@ import SearchIcon from '@mui/icons-material/Search'
|
||||
import { componentCatalog } from '@/lib/component-catalog'
|
||||
import type { ComponentDefinition } from '@/lib/builder-types'
|
||||
|
||||
const iconMap: Record<string, React.ComponentType<SvgIconProps>> = {
|
||||
const iconMap: Record<string, ComponentType<SvgIconProps>> = {
|
||||
FrameCorners: CropFreeIcon,
|
||||
Columns: ViewColumnIcon,
|
||||
GridFour: GridViewIcon,
|
||||
|
||||
8
frontends/nextjs/src/lib/db/dbal-client/close-adapter.ts
Normal file
8
frontends/nextjs/src/lib/db/dbal-client/close-adapter.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { prismaAdapter } from './create-prisma-adapter'
|
||||
|
||||
/**
|
||||
* Close the DBAL adapter connection
|
||||
*/
|
||||
export const closeAdapter = async (): Promise<void> => {
|
||||
await prismaAdapter.close()
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import type { DBALAdapter } from './types'
|
||||
import { closeConnection } from './close-connection'
|
||||
import { createEntity } from './create-entity'
|
||||
import { deleteEntity } from './delete-entity'
|
||||
import { findFirstEntity } from './find-first-entity'
|
||||
import { listEntities } from './list-entities'
|
||||
import { readEntity } from './read-entity'
|
||||
import { updateEntity } from './update-entity'
|
||||
import { upsertEntity } from './upsert-entity'
|
||||
|
||||
/**
|
||||
* DBAL Adapter implementation using Prisma
|
||||
*/
|
||||
export const prismaAdapter: DBALAdapter = {
|
||||
create: createEntity,
|
||||
read: readEntity,
|
||||
update: updateEntity,
|
||||
delete: deleteEntity,
|
||||
list: listEntities,
|
||||
findFirst: findFirstEntity,
|
||||
upsert: upsertEntity,
|
||||
close: closeConnection,
|
||||
}
|
||||
9
frontends/nextjs/src/lib/db/dbal-client/get-adapter.ts
Normal file
9
frontends/nextjs/src/lib/db/dbal-client/get-adapter.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import type { DBALAdapter } from './types'
|
||||
import { prismaAdapter } from './create-prisma-adapter'
|
||||
|
||||
/**
|
||||
* Get the DBAL adapter singleton for database operations
|
||||
*/
|
||||
export const getAdapter = (): DBALAdapter => {
|
||||
return prismaAdapter
|
||||
}
|
||||
Reference in New Issue
Block a user