UNPKG

prisma-util

Version:

Prisma Util is an easy to use tool that merges multiple Prisma schema files, allows extending of models, resolves naming conflicts both manually and automatically and provides easy access to Prisma commands and timing reports. It's mostly a plug-and-play

26 lines (25 loc) 896 B
import { getConfig } from "./config.js"; export default function getMappings() { const config = getConfig(); if (!config.defaultFunctions) return { columnMappings: {}, modelMappings: {} }; const entries = Object.entries(config.defaultFunctions).map(entry => { return [entry[0].split(":")[1], entry[1]]; }); const columnMappings = Object.fromEntries(entries); const modelMappings = {}; for (const [modelColumn, func] of entries) { const [modelName, columnName] = modelColumn.split("."); if (modelMappings[modelName]) modelMappings[modelName][columnName] = func; else modelMappings[modelName] = { [columnName]: func }; } return { columnMappings, modelMappings }; } export function getStaticTake() { const config = getConfig(); if (!config.take) return {}; return config.take; }