Shayokh
Shayokh
Explore posts from servers
DTDrizzle Team
Created by Shayokh on 8/15/2024 in #help
⚠ Error - Top-level await is currently not supported with the "cjs" output format
I will try them and inform which one did the job :]
26 replies
DTDrizzle Team
Created by Shayokh on 8/15/2024 in #help
⚠ Error - Top-level await is currently not supported with the "cjs" output format
Thanks a lot
26 replies
DTDrizzle Team
Created by Shayokh on 8/15/2024 in #help
⚠ Error - Top-level await is currently not supported with the "cjs" output format
No description
26 replies
DTDrizzle Team
Created by Shayokh on 8/15/2024 in #help
⚠ Error - Top-level await is currently not supported with the "cjs" output format
I added "type" : "module" and now I am getting this new error -
PS D:\Typescript\drizzle orm\drizzle_test> npm run db:migrate

> drizzle_test@0.1.0 db:migrate
> tsx migrate.ts

D:\Typescript\drizzle orm\drizzle_test\node_modules\src\migrator.ts:41
throw new Error(`Can't find meta/_journal.json file`);
^


Error: Can't find meta/_journal.json file
at readMigrationFiles (D:\Typescript\drizzle orm\drizzle_test\node_modules\src\migrator.ts:41:9)
at migrate (D:\Typescript\drizzle orm\drizzle_test\node_modules\src\mysql2\migrator.ts:9:21)
at <anonymous> (D:\Typescript\drizzle orm\drizzle_test\migrate.ts:6:7)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v22.3.0
PS D:\Typescript\drizzle orm\drizzle_test> npm run db:migrate

> drizzle_test@0.1.0 db:migrate
> tsx migrate.ts

D:\Typescript\drizzle orm\drizzle_test\node_modules\src\migrator.ts:41
throw new Error(`Can't find meta/_journal.json file`);
^


Error: Can't find meta/_journal.json file
at readMigrationFiles (D:\Typescript\drizzle orm\drizzle_test\node_modules\src\migrator.ts:41:9)
at migrate (D:\Typescript\drizzle orm\drizzle_test\node_modules\src\mysql2\migrator.ts:9:21)
at <anonymous> (D:\Typescript\drizzle orm\drizzle_test\migrate.ts:6:7)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v22.3.0
26 replies
DTDrizzle Team
Created by Shayokh on 8/15/2024 in #help
⚠ Error - Top-level await is currently not supported with the "cjs" output format
Same error
26 replies
DTDrizzle Team
Created by Shayokh on 8/15/2024 in #help
⚠ Error - Top-level await is currently not supported with the "cjs" output format
IIFE didnt work
26 replies
DTDrizzle Team
Created by Shayokh on 8/15/2024 in #help
⚠ Error - Top-level await is currently not supported with the "cjs" output format
I mean what should I add or remove?
26 replies
DTDrizzle Team
Created by Shayokh on 8/15/2024 in #help
⚠ Error - Top-level await is currently not supported with the "cjs" output format
How do I change the ts config?
26 replies
DTDrizzle Team
Created by Shayokh on 8/15/2024 in #help
⚠ Error - Top-level await is currently not supported with the "cjs" output format
I additionally added these - tsconfig -
"module": "es2022",
"target": "ES2017",
"module": "es2022",
"target": "ES2017",
package.json -
"db:generate": "npx drizzle-kit generate",
"db:migrate": "tsx migrate.ts"
"db:generate": "npx drizzle-kit generate",
"db:migrate": "tsx migrate.ts"
26 replies
DTDrizzle Team
Created by Shayokh on 8/15/2024 in #help
⚠ Error - Top-level await is currently not supported with the "cjs" output format
Migrate.ts -
import "dotenv/config";
import { migrate } from "drizzle-orm/mysql2/migrator";
import { db, connection } from "./db";

// This will run migrations on the database, skipping the ones already applied
await migrate(db, { migrationsFolder: "./drizzle" });

// Don't forget to close the connection, otherwise the script will hang
await connection.end();
import "dotenv/config";
import { migrate } from "drizzle-orm/mysql2/migrator";
import { db, connection } from "./db";

// This will run migrations on the database, skipping the ones already applied
await migrate(db, { migrationsFolder: "./drizzle" });

// Don't forget to close the connection, otherwise the script will hang
await connection.end();
db.ts -
import { drizzle } from "drizzle-orm/mysql2";
import mysql from "mysql2/promise";
import * as schema from "./drizzle/schema";

export const connection = await mysql.createConnection({
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
multipleStatements: true,
});

export const db = drizzle(connection, { schema, mode: "default" });
import { drizzle } from "drizzle-orm/mysql2";
import mysql from "mysql2/promise";
import * as schema from "./drizzle/schema";

export const connection = await mysql.createConnection({
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
multipleStatements: true,
});

export const db = drizzle(connection, { schema, mode: "default" });
drizzle config -
import { defineConfig } from "drizzle-kit";

export default defineConfig({
schema: "./drizzle/schema.ts",
out: "./drizzle/migrations",
dialect: "mysql",
verbose: true,
strict: true,

dbCredentials: {
url: process.env.DATABASE_URL as string,
},
});
import { defineConfig } from "drizzle-kit";

export default defineConfig({
schema: "./drizzle/schema.ts",
out: "./drizzle/migrations",
dialect: "mysql",
verbose: true,
strict: true,

dbCredentials: {
url: process.env.DATABASE_URL as string,
},
});
26 replies
DTDrizzle Team
Created by Shayokh on 8/14/2024 in #help
Weird numbers in terminal 💀
Thanks a lot! Coming from Prisma as a refugee, I am loving Drizzle so far. Its my go-to ORM now :]
10 replies
DTDrizzle Team
Created by Shayokh on 8/14/2024 in #help
Weird numbers in terminal 💀
Just to be clear, its not a major issue right?
10 replies
DTDrizzle Team
Created by Shayokh on 8/14/2024 in #help
Weird numbers in terminal 💀
Maybe
10 replies
DTDrizzle Team
Created by Shayokh on 8/14/2024 in #help
Weird numbers in terminal 💀
Are these texts normal?
10 replies
DTDrizzle Team
Created by Shayokh on 8/14/2024 in #help
Weird numbers in terminal 💀
drizzle config -
import { defineConfig } from "drizzle-kit";

export default defineConfig({
schema: "./drizzle/schema.ts",
out: "./drizzle/migrations",
dialect: "mysql",
verbose: true,
strict: true,

dbCredentials: {
url: process.env.DATABASE_URL as string,
},
});
import { defineConfig } from "drizzle-kit";

export default defineConfig({
schema: "./drizzle/schema.ts",
out: "./drizzle/migrations",
dialect: "mysql",
verbose: true,
strict: true,

dbCredentials: {
url: process.env.DATABASE_URL as string,
},
});
10 replies
DTDrizzle Team
Created by Shayokh on 8/14/2024 in #help
Weird numbers in terminal 💀
Schema -
import { mysqlTable, serial, varchar } from "drizzle-orm/mysql-core";
import {} from "drizzle-orm/mysql2";

export const UserTable = mysqlTable("users ", {
id: serial("id").primaryKey(),
name: varchar("name", { length: 255 }).notNull(),
});
import { mysqlTable, serial, varchar } from "drizzle-orm/mysql-core";
import {} from "drizzle-orm/mysql2";

export const UserTable = mysqlTable("users ", {
id: serial("id").primaryKey(),
name: varchar("name", { length: 255 }).notNull(),
});
10 replies
DTDrizzle Team
Created by Shayokh on 8/14/2024 in #help
Help! Can't install drizzle-orm
Ohh. I hope it gets fixed soon. Thanks a lot! ✨
4 replies