drizzle-orm icon indicating copy to clipboard operation
drizzle-orm copied to clipboard

[BUG]: Property 'batch' does not exist on type 'NeonDatabase'

Open JJZFIVE opened this issue 1 year ago • 2 comments

What version of drizzle-orm are you using?

^0.33.0

What version of drizzle-kit are you using?

No response

Describe the Bug

When I try to use db.batch(), it gives me the error: Property 'batch' does not exist on type 'NeonDatabase'

I'm using Neon as my postgres provider and am initializing my db object as such:

import { drizzle } from "drizzle-orm/neon-serverless";
import { Config } from "../config";
import { Pool, neonConfig } from "@neondatabase/serverless";
import ws from "ws";
neonConfig.webSocketConstructor = ws;

import * as schema from "../../../shared/db/";

const pool = new Pool({
	connectionString: Config.POSTGRES_POOL_URI,
});

const db = drizzle(pool, { schema });
export default db;
export { pool };

Expected behavior

The Drizzle batch docs appear to claim support for Neon: https://orm.drizzle.team/docs/batch-api

Environment & setup

No response

JJZFIVE avatar Sep 17 '24 17:09 JJZFIVE

I've just run into the same issue. Did you find any resolution @JJZFIVE ?

Looks like it's only on 'drizzle-orm/neon-http', not serverless

sammyjoyce avatar Oct 01 '24 03:10 sammyjoyce

I've just run into the same issue. Did you find any resolution @JJZFIVE ?

Looks like it's only on 'drizzle-orm/neon-http', not serverless

Interesting. Drizzle team, is this expected behavior?

JJZFIVE avatar Oct 01 '24 14:10 JJZFIVE

It seems to me that if I specify max: 1 it behaves the same way without wrapping my queries in a batch. I might be wrong - hope thought that I'm not.

import { drizzle, NeonDatabase } from 'drizzle-orm/neon-serverless';
import { neonConfig, Pool } from '@neondatabase/serverless';
 const pool = new Pool({
        connectionString: POSTGRES_NEON_DB_URL,
        max: 1,
    });
  const db = drizzle(pool, {
        logger: true,
    });

flexchar avatar Nov 03 '24 14:11 flexchar

Yes, it's available on neon-http, because only there you can send batch statements

AndriiSherman avatar Dec 16 '24 18:12 AndriiSherman