Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@exlabs/clickhouse-prisma-adapter

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@exlabs/clickhouse-prisma-adapter

Clickhouse adapter for Prisma

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
0
Weekly downloads
 
Created
Source

Clickhouse Prisma Adapter

Installation

Install the adapter using npm:

npm install @exlabs/clickhouse-prisma-adapter

Make sure that you have the following dependencies installed:

  • Prisma
  • Clickhouse

Usage

Step 1: Add the adapter to your Prisma schema

Add the adapter to your Prisma schema file:

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["driverAdapters"]
}

datasource db {
  provider = "mysql"
  url      = env("DATABASE_URL")
}

Make sure that prisma schema reflects the schema of the Clickhouse database.

Note that the driverAdapters preview feature is required to use the adapter. Datasource provider should be set to mysql. This is a workaround to make Prisma CLI generate the client.

After updating the schema, run the following command to generate the Prisma client:

npx prisma generate

Step 2: Configure the adapter

Create new file, for example clickhouse-adapter.ts and add the following code:

import { createClient } from "@clickhouse/client";
import { PrismaClient } from "@prisma/client";
import ClickhousePrismaAdapter from "@exlabs/clickhouse-prisma-adapter";

export const client = createClient({
  url: "http://localhost:8123",
  password: "",
  username: "default",
  database: "default",
});

const adapter = new ClickhousePrismaAdapter({ client, schemaName: "default" });

export const prisma = new PrismaClient({ adapter });

Step 3: Use the adapter

Now you can use the adapter in your application:

import { prisma } from "./clickhouse-adapter";

async function main() {
  const users = await prisma.user.findMany();
  console.log(users);
}

Keywords

FAQs

Package last updated on 10 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc