Variable prismaConst

prisma: {
    client: {
        addData: (<const PrismaClient>(prismaClient: Readonly<PrismaClient>, data: IsAny<PrismaClient> extends true
            ? any
            : PrismaAddModelData<PrismaClient>) => Promise<void>);
        dumpData: (<const PrismaClient>(prismaClient: PrismaClient, options?: Readonly<PartialWithUndefined<PrismaDataDumpOptions>>) => Promise<PrismaAllBasicModels<PrismaClient>>);
        generate: ((schemaFilePath: string, env?: Record<string, string>) => Promise<void>);
        isCurrent: ((__namedParameters: {
            jsClientOutputDir: string;
            schemaFilePath: string;
        }) => Promise<boolean>);
        listModelNames: (<const PrismaClient>(prismaClient: PrismaClient) => PrismaModelName<PrismaClient>[]);
    };
    database: {
        diff: ((schemaFilePath: string, env?: Record<string, string>) => Promise<string>);
        hasDiff: ((schemaFilePath: string, env?: Record<string, string>) => Promise<boolean>);
        resetDev: ((schemaFilePath: string, env?: Record<string, string>) => Promise<void>);
    };
    migration: {
        applyDev: ((schemaFilePath: string, env?: Record<string, string>) => Promise<void>);
        applyProd: ((schemaFilePath: string, env?: Record<string, string>) => Promise<void>);
        create: ((__namedParameters: {
            createOnly?: boolean;
            migrationName: string;
        }, schemaFilePath: string, env?: Record<string, string>) => Promise<void>);
        status: ((schemaFilePath: string, env?: Record<string, string>) => Promise<PrismaMigrationStatus>);
    };
} = ...

Centralized Prisma API from @augment-vir/node.

Type declaration

  • client: {
        addData: (<const PrismaClient>(prismaClient: Readonly<PrismaClient>, data: IsAny<PrismaClient> extends true
            ? any
            : PrismaAddModelData<PrismaClient>) => Promise<void>);
        dumpData: (<const PrismaClient>(prismaClient: PrismaClient, options?: Readonly<PartialWithUndefined<PrismaDataDumpOptions>>) => Promise<PrismaAllBasicModels<PrismaClient>>);
        generate: ((schemaFilePath: string, env?: Record<string, string>) => Promise<void>);
        isCurrent: ((__namedParameters: {
            jsClientOutputDir: string;
            schemaFilePath: string;
        }) => Promise<boolean>);
        listModelNames: (<const PrismaClient>(prismaClient: PrismaClient) => PrismaModelName<PrismaClient>[]);
    }
    • addData: (<const PrismaClient>(prismaClient: Readonly<PrismaClient>, data: IsAny<PrismaClient> extends true
          ? any
          : PrismaAddModelData<PrismaClient>) => Promise<void>)

      Adds a collection of create data to a database through a PrismaClient instance. This is particularly useful for setting up mocks in a mock PrismaClient.

      import {addPrismaModelData} from '@augment-vir/common';
      import {PrismaClient} from '@prisma/client';

      await addPrismaModelData(new 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.
      },
      ],
      },
      ]);
    • dumpData: (<const PrismaClient>(prismaClient: PrismaClient, options?: Readonly<PartialWithUndefined<PrismaDataDumpOptions>>) => Promise<PrismaAllBasicModels<PrismaClient>>)

      Dump data from the current database through a PrismaClient instance.

    • generate: ((schemaFilePath: string, env?: Record<string, string>) => Promise<void>)

      Runs Prisma generators included in the given Prisma schema (which usually includes the Prisma JS client). This will work even if the database doesn't exist yet.

      import {prisma} from '@augment-vir/node';

      prisma.client.generate('../../prisma/schema.prisma');
        • (schemaFilePath, env?): Promise<void>
        • Parameters

          • schemaFilePath: string
          • env: Record<string, string> = {}

          Returns Promise<void>

    • isCurrent: ((__namedParameters: {
          jsClientOutputDir: string;
          schemaFilePath: string;
      }) => Promise<boolean>)

      Detects if the current generated Prisma JS Client was generated from the current Prisma schema.

        • (__namedParameters): Promise<boolean>
        • Parameters

          • __namedParameters: {
                jsClientOutputDir: string;
                schemaFilePath: string;
            }
            • jsClientOutputDir: string
            • schemaFilePath: string

          Returns Promise<boolean>

    • listModelNames: (<const PrismaClient>(prismaClient: PrismaClient) => PrismaModelName<PrismaClient>[])

      List all model names in the given Prisma client.

  • database: {
        diff: ((schemaFilePath: string, env?: Record<string, string>) => Promise<string>);
        hasDiff: ((schemaFilePath: string, env?: Record<string, string>) => Promise<boolean>);
        resetDev: ((schemaFilePath: string, env?: Record<string, string>) => Promise<void>);
    }
    • diff: ((schemaFilePath: string, env?: Record<string, string>) => Promise<string>)

      Gets a string list of all differences between the current database and the Prisma schema that should control it.

        • (schemaFilePath, env?): Promise<string>
        • Parameters

          • schemaFilePath: string
          • env: Record<string, string> = {}

          Returns Promise<string>

    • hasDiff: ((schemaFilePath: string, env?: Record<string, string>) => Promise<boolean>)

      Uses prisma.database.diff to detect if there are any differences between the current database and the Prisma schema that should control it.

        • (schemaFilePath, env?): Promise<boolean>
        • Parameters

          • schemaFilePath: string
          • env: Record<string, string> = {}

          Returns Promise<boolean>

    • resetDev: ((schemaFilePath: string, env?: Record<string, string>) => Promise<void>)

      Force resets a dev database to match the current Prisma schema and migrations.

      This will destroy all data. Do not use in production.

        • (schemaFilePath, env?): Promise<void>
        • Parameters

          • schemaFilePath: string
          • env: Record<string, string> = {}

          Returns Promise<void>

  • migration: {
        applyDev: ((schemaFilePath: string, env?: Record<string, string>) => Promise<void>);
        applyProd: ((schemaFilePath: string, env?: Record<string, string>) => Promise<void>);
        create: ((__namedParameters: {
            createOnly?: boolean;
            migrationName: string;
        }, schemaFilePath: string, env?: Record<string, string>) => Promise<void>);
        status: ((schemaFilePath: string, env?: Record<string, string>) => Promise<PrismaMigrationStatus>);
    }
    • applyDev: ((schemaFilePath: string, env?: Record<string, string>) => Promise<void>)

      Apply all migrations. Meant for a development environment, with less protections than prisma.migration.applyProd.

      PrismaMigrationNeededError when a new migration is required so the user needs to input a name.

      PrismaResetNeededError when there's a migration mismatch with the database and it needs to be reset.

        • (schemaFilePath, env?): Promise<void>
        • Parameters

          • schemaFilePath: string
          • env: Record<string, string> = {}

          Returns Promise<void>

    • applyProd: ((schemaFilePath: string, env?: Record<string, string>) => Promise<void>)

      Apply all migrations. Meant for a production environment.

        • (schemaFilePath, env?): Promise<void>
        • Parameters

          • schemaFilePath: string
          • env: Record<string, string> = {}

          Returns Promise<void>

    • create: ((__namedParameters: {
          createOnly?: boolean;
          migrationName: string;
      }, schemaFilePath: string, env?: Record<string, string>) => Promise<void>)

      Creates a new migration.

        • (__namedParameters, schemaFilePath, env?): Promise<void>
        • Parameters

          • __namedParameters: {
                createOnly?: boolean;
                migrationName: string;
            }
            • OptionalcreateOnly?: boolean

              Set this to true to create a new migration without applying it to the database.

              false
              
            • migrationName: string
          • schemaFilePath: string
          • env: Record<string, string> = {}

          Returns Promise<void>

    • status: ((schemaFilePath: string, env?: Record<string, string>) => Promise<PrismaMigrationStatus>)

      Get current migration status.