SteveS
SteveS
DTDrizzle Team
Created by SteveS on 6/11/2024 in #help
Why is it the case that my IDE says `await` does nothing on pretty much every single function?
I can't figure out any reason this wouldn't work:
import { Database } from "bun:sqlite"
import { $ } from "bun";
import { seedDb } from "./seed";
import { drizzle } from 'drizzle-orm/bun-sqlite';
import { usersTable } from "./src/lib/server/db/schema";

await $`rm -rf dev.db`

const sqlite = new Database("dev.db", {
readwrite: true,
create: true,
});

await $`bun drizzle-kit migrate`

const db = drizzle(sqlite);

console.log();

console.log("/n")
console.log("inserting test user");
await db.insert(usersTable).values({ id: "1", username: "test" });

console.log("getting test user");
const data = await db.select().from(usersTable);
await seedDb(sqlite);
import { Database } from "bun:sqlite"
import { $ } from "bun";
import { seedDb } from "./seed";
import { drizzle } from 'drizzle-orm/bun-sqlite';
import { usersTable } from "./src/lib/server/db/schema";

await $`rm -rf dev.db`

const sqlite = new Database("dev.db", {
readwrite: true,
create: true,
});

await $`bun drizzle-kit migrate`

const db = drizzle(sqlite);

console.log();

console.log("/n")
console.log("inserting test user");
await db.insert(usersTable).values({ id: "1", username: "test" });

console.log("getting test user");
const data = await db.select().from(usersTable);
await seedDb(sqlite);
2 replies
DTDrizzle Team
Created by SteveS on 8/16/2023 in #help
Error following push
I really can't remember much of this. Looks like I was pushing changes to a table, like adding a column, and when I did that it would make intermediary tables. In this case it was a table of resume information. I probably had a FK constraint with a user table and then added a column
4 replies
DTDrizzle Team
Created by SteveS on 10/17/2023 in #help
How to get better errors?
I guess I'm thinking of if the eq() function could compare types to make sure that they are the same it would be really useful.
2 replies
DTDrizzle Team
Created by SteveS on 10/14/2023 in #help
drizzle-zod: remove ID from insert schema type
So, I have a schema for a db table. I want to create an insert schema. The ID is auto incremented. I therefore do not need the ID field as part of the insert schema.
4 replies
DTDrizzle Team
Created by Graeme on 6/27/2023 in #help
Unexpected type mismatch for sqlite integer boolean mode
Just running into this myself and I'm not sure I understand the design philosophy. An integer taking "true" or "false" as a value seems like an anti-pattern to me.
9 replies
DTDrizzle Team
Created by SteveS on 8/16/2023 in #help
Error following push
This error was due to me previously adding a foreign key constraint to one of my tables, then removing/updating the table it was referring to. sqlite doesn't allow foreign keys to be dropped. I had to create a new table without the fk, copy over all the data, drop the old table, and rename the new table to the old one. Now it works.
4 replies
DTDrizzle Team
Created by SteveS on 8/15/2023 in #help
How to debug Drizzle queries
Yeah, I don't want to be too needy, but if something is being worked on or isn't stable it would be nice to know. I'm sure they are aware the value that good docs has in the fast moving web space. It's not like I'm going to stop using Drizzle though. I couldn't really stand prisma so its a big improvement
45 replies
DTDrizzle Team
Created by SteveS on 8/15/2023 in #help
How to debug Drizzle queries
Ah, ok. In the future I would recommend updating the docs with warnings or something. I love what you guys are doing, but I spent the last hour and a half on this.
45 replies
DTDrizzle Team
Created by SteveS on 8/15/2023 in #help
How to debug Drizzle queries
I don't have to do that for the other drivers? Extremely strange that I have to do that for libsql
45 replies
DTDrizzle Team
Created by SteveS on 8/15/2023 in #help
How to debug Drizzle queries
oml if I use .run() at the end it runs
45 replies
DTDrizzle Team
Created by SteveS on 8/15/2023 in #help
How to debug Drizzle queries
SQLiteInsert {
session: LibSQLSession {
dialect: SQLiteAsyncDialect {},
client: HttpClient { protocol: 'http' },
schema: { fullSchema: [Object], schema: [Object], tableNamesMap: [Object] },
options: { logger: [DefaultLogger] },
tx: undefined,
logger: DefaultLogger { writer: ConsoleLogWriter {} }
},
dialect: SQLiteAsyncDialect {},
config: {
table: SQLiteTable {
id: [SQLiteInteger],
userId: [SQLiteText],
firstName: [SQLiteText],
lastName: [SQLiteText],
address: [SQLiteText],
phone: [SQLiteText],
linkedin_url: [SQLiteText],
statement: [SQLiteText],
[Symbol(drizzle:Name)]: 'personal_information',
[Symbol(drizzle:OriginalName)]: 'personal_information',
[Symbol(drizzle:Schema)]: undefined,
[Symbol(drizzle:Columns)]: [Object],
[Symbol(drizzle:BaseName)]: 'personal_information',
[Symbol(drizzle:IsAlias)]: false,
[Symbol(drizzle:ExtraConfigBuilder)]: undefined,
[Symbol(drizzle:IsDrizzleTable)]: true,
[Symbol(drizzle:SQLiteInlineForeignKeys)]: [Array]
},
values: [ [Object] ]
},
run: [Function: run],
all: [Function: all],
get: [Function: get],
values: [Function: values]
}
SQLiteInsert {
session: LibSQLSession {
dialect: SQLiteAsyncDialect {},
client: HttpClient { protocol: 'http' },
schema: { fullSchema: [Object], schema: [Object], tableNamesMap: [Object] },
options: { logger: [DefaultLogger] },
tx: undefined,
logger: DefaultLogger { writer: ConsoleLogWriter {} }
},
dialect: SQLiteAsyncDialect {},
config: {
table: SQLiteTable {
id: [SQLiteInteger],
userId: [SQLiteText],
firstName: [SQLiteText],
lastName: [SQLiteText],
address: [SQLiteText],
phone: [SQLiteText],
linkedin_url: [SQLiteText],
statement: [SQLiteText],
[Symbol(drizzle:Name)]: 'personal_information',
[Symbol(drizzle:OriginalName)]: 'personal_information',
[Symbol(drizzle:Schema)]: undefined,
[Symbol(drizzle:Columns)]: [Object],
[Symbol(drizzle:BaseName)]: 'personal_information',
[Symbol(drizzle:IsAlias)]: false,
[Symbol(drizzle:ExtraConfigBuilder)]: undefined,
[Symbol(drizzle:IsDrizzleTable)]: true,
[Symbol(drizzle:SQLiteInlineForeignKeys)]: [Array]
},
values: [ [Object] ]
},
run: [Function: run],
all: [Function: all],
get: [Function: get],
values: [Function: values]
}
45 replies
DTDrizzle Team
Created by SteveS on 8/15/2023 in #help
How to debug Drizzle queries
Do I have to "run" the insert?
45 replies
DTDrizzle Team
Created by SteveS on 8/15/2023 in #help
How to debug Drizzle queries
Is there something possibly wrong with the libsql connector?
45 replies
DTDrizzle Team
Created by SteveS on 8/15/2023 in #help
How to debug Drizzle queries
if I await a query, it works fine. But awaiting an insert doesn't do anything
45 replies
DTDrizzle Team
Created by SteveS on 8/15/2023 in #help
How to debug Drizzle queries
I'm looking through and it seems exactly the same. The only difference is that I'm using Turso in the new project
45 replies
DTDrizzle Team
Created by SteveS on 8/15/2023 in #help
How to debug Drizzle queries
This might be a SvelteKit issue. I have a project that works perfectly fine and it doesn't have the async warning when using await.
45 replies
DTDrizzle Team
Created by SteveS on 8/15/2023 in #help
How to debug Drizzle queries
So the insert isn't even running
45 replies
DTDrizzle Team
Created by SteveS on 8/15/2023 in #help
How to debug Drizzle queries
The select you are seeing in the above occurs when the page reloads
45 replies
DTDrizzle Team
Created by SteveS on 8/15/2023 in #help
How to debug Drizzle queries
TypeScript
45 replies
DTDrizzle Team
Created by SteveS on 8/15/2023 in #help
How to debug Drizzle queries
anything <-- this is logged when the action is run
Query: select "id", "user_id", "first_name", "last_name", "address", "phone", "linkedin_url", "statement" from "personal_information" "personalInformationTable" where "personalInformationTable"."user_id" = ? limit ? -- params: ["3zx69w1e8w6ghkz", 1]
{
id: 1,
userId: '3zx69w1e8w6ghkz',
firstName: 'steve',
lastName: null,
address: null,
phone: null,
linkedin_url: null,
statement: null
}
anything <-- this is logged when the action is run
Query: select "id", "user_id", "first_name", "last_name", "address", "phone", "linkedin_url", "statement" from "personal_information" "personalInformationTable" where "personalInformationTable"."user_id" = ? limit ? -- params: ["3zx69w1e8w6ghkz", 1]
{
id: 1,
userId: '3zx69w1e8w6ghkz',
firstName: 'steve',
lastName: null,
address: null,
phone: null,
linkedin_url: null,
statement: null
}
45 replies