Drizzle & Postgres JS - "postgres is not a function"
I'm using NestJS v10.3.6
package-json:
here's what i found inside the
package-json:
"drizzle-orm": ^0.30.10,
"postgres": ^3.4.4,"drizzle-orm": ^0.30.10,
"postgres": ^3.4.4,2024-05-10 01:48:34 [Nest] 53 - 05/09/2024, 6:48:34 PM ERROR [ExceptionsHandler] (0 , postgres_1.default) is not a function
2024-05-10 01:48:34 TypeError: (0 , postgres_1.default) is not a function2024-05-10 01:48:34 [Nest] 53 - 05/09/2024, 6:48:34 PM ERROR [ExceptionsHandler] (0 , postgres_1.default) is not a function
2024-05-10 01:48:34 TypeError: (0 , postgres_1.default) is not a functionimport { Injectable } from '@nestjs/common'
import { drizzle } from 'drizzle-orm/postgres-js'
import postgres from 'postgres'
import * as schema from 'src/schema'
@Injectable()
export class UsersService {
async getAll(): Promise<(typeof schema.users.$inferSelect)[]> {
const client = postgres('postgres://root:root@postgres:5432/testing', { // <== Here's the problem
ssl: false,
})
const db = drizzle(client, { schema })
// queries
}
}import { Injectable } from '@nestjs/common'
import { drizzle } from 'drizzle-orm/postgres-js'
import postgres from 'postgres'
import * as schema from 'src/schema'
@Injectable()
export class UsersService {
async getAll(): Promise<(typeof schema.users.$inferSelect)[]> {
const client = postgres('postgres://root:root@postgres:5432/testing', { // <== Here's the problem
ssl: false,
})
const db = drizzle(client, { schema })
// queries
}
}here's what i found inside the
/dist/dist directory :const common_1 = require("@nestjs/common");
const postgres_js_1 = require("drizzle-orm/postgres-js");
const postgres_1 = require("postgres");
const schema = require("../../schema");
let UsersService = class UsersService {
async getAll() {
const client = (0, postgres_1.default)('postgres://root:root@postgres:5432/testing', { // PROBLEM!!
ssl: false,
});
const db = (0, postgres_js_1.drizzle)(client, { schema });
const users = await db.select().from(schema.users);
return users;
}
};const common_1 = require("@nestjs/common");
const postgres_js_1 = require("drizzle-orm/postgres-js");
const postgres_1 = require("postgres");
const schema = require("../../schema");
let UsersService = class UsersService {
async getAll() {
const client = (0, postgres_1.default)('postgres://root:root@postgres:5432/testing', { // PROBLEM!!
ssl: false,
});
const db = (0, postgres_js_1.drizzle)(client, { schema });
const users = await db.select().from(schema.users);
return users;
}
};