UNPKG

@augment-vir/node

Version:

A collection of augments, helpers types, functions, and classes only for Node.js (backend) JavaScript environments.

75 lines (74 loc) 2.82 kB
import { type BasePrismaClient, type PartialWithUndefined, type PrismaAllBasicModels, type PrismaAllModelsCreate, type PrismaModelName } from '@augment-vir/common'; import { type IsAny } from 'type-fest'; /** * Params for `prisma.client.addData()`. This is similar to {@link PrismaAllModelsCreate} but allows * an array of {@link PrismaAllModelsCreate} for sequential data creation. * * @category Prisma : Node * @category Package : @augment-vir/node * @example * * ```ts * import {PrismaAddModelData} from '@augment-vir/common'; * import {type PrismaClient} from '@prisma/client'; * * const mockData: PrismaAddModelData<PrismaClient> = [ * { * user: { * mockUser1: { * first_name: 'one', * id: 123, * // etc. * }, * mockUser2: { * first_name: 'two', * id: 124, * authRole: 'user', * // etc. * }, * }, * }, * { * region: [ * { * id: 1, * name: 'North America', * // etc. * }, * { * id: 2, * name: 'Europe', * // etc. * }, * ], * }, * ]; * ``` * * @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node) */ export type PrismaAddDataData<PrismaClient extends BasePrismaClient> = Readonly<PrismaAllModelsCreate<PrismaClient>> | ReadonlyArray<Readonly<PrismaAllModelsCreate<PrismaClient>>>; export declare function addData<const PrismaClient extends BasePrismaClient>(prismaClient: Readonly<PrismaClient>, data: IsAny<PrismaClient> extends true ? any : PrismaAddDataData<PrismaClient>): Promise<void>; export declare function getAllPrismaModelNames<const PrismaClient extends BasePrismaClient>(prismaClient: PrismaClient): PrismaModelName<PrismaClient>[]; /** * Options for `prisma.client.dumpData`. * * @category Prisma : Node * @category Package : @augment-vir/node * @package [`@augment-vir/node`](https://www.npmjs.com/package/@augment-vir/node) */ export type PrismaDataDumpOptions = { /** * The max number of entries to load per model. Set to `0` to remove this limit altogether * (which could be _very_ expensive for your database). * * @default 100 */ limit: number; /** * Strings to omit from the dumped data. For testability, omitting date or UUID id fields is a * common practice. */ omitFields: string[]; }; export declare function dumpData<const PrismaClient extends BasePrismaClient>(prismaClient: PrismaClient, options?: Readonly<PartialWithUndefined<PrismaDataDumpOptions>>): Promise<PrismaAllBasicModels<PrismaClient>>;