DJS Commandsv2 docs
API ReferenceAdapters

adapter-prisma

Prisma Storage adapter — prismaStorage, options, schema fragments.

bun add @djs-commands/core @djs-commands/adapter-prisma @prisma/client
bun add -d prisma

For setup (schema model copies, migrations) see Adapter Cookbook → Prisma.

prismaStorage(prisma, options?)

function prismaStorage(
	prisma: PrismaClientLike,
	options?: PrismaStorageOptions,
): Storage;

Returns a Storage backed by a Prisma Client.

import { prismaStorage } from "@djs-commands/adapter-prisma";
import { PrismaClient } from "@prisma/client";

const prisma = new PrismaClient();

createCommandHandler({
	client,
	commands: [...],
	storage: prismaStorage(prisma),
});

PrismaClientLike

type PrismaClientLike = Record<string, unknown>;

Intentionally loose typing so the package doesn't require @prisma/client as a hard dependency. The adapter accesses delegates by name (prisma.guildPrefix.findUnique(...) etc.).

PrismaStorageOptions

interface PrismaStorageOptions {
	delegates?: Partial<{
		guildPrefix: unknown;
		disabledCommands: unknown;
		channelLocks: unknown;
	}>;
}

If you renamed the framework models in your schema, pass the delegates explicitly:

prismaStorage(prisma, {
	delegates: { guildPrefix: prisma.myCustomGuildPrefix },
});

Schema fragment exports

import {
	GUILD_PREFIX_PRISMA_MODEL,
	DISABLED_COMMANDS_PRISMA_MODEL,
	CHANNEL_LOCKS_PRISMA_MODEL,
} from "@djs-commands/adapter-prisma";

Each is a multi-line string containing the Prisma DSL for that model. Use them programmatically (e.g. for codegen / docs); for everyday use, copy the model definitions into your schema.prisma directly:

model GuildPrefix {
	guildId String @id @map("guild_id")
	prefix  String

	@@map("guild_prefix")
}

(See the cookbook for the full set.)

Last updated on

On this page