sten
sten
Explore posts from servers
DTDrizzle Team
Created by 26thavenue on 1/4/2024 in #help
Error using the query param
The relations are exported from the schema so I would assume they're also imported. When I make a db call, I simply reference teh D1 instance on event.locals.D1 that is previously setup.
16 replies
DTDrizzle Team
Created by 26thavenue on 1/4/2024 in #help
Error using the query param
I'm not type expert here
16 replies
DTDrizzle Team
Created by 26thavenue on 1/4/2024 in #help
Error using the query param
drizzle return type is : DrizzleD1Database<typeof schema>
16 replies
DTDrizzle Team
Created by 26thavenue on 1/4/2024 in #help
Error using the query param
import * as schema from '$lib/db/schema';

D1: DrizzleD1Database<schema>;
import * as schema from '$lib/db/schema';

D1: DrizzleD1Database<schema>;
16 replies
DTDrizzle Team
Created by 26thavenue on 1/4/2024 in #help
Error using the query param
But I am missing the schema... so I guess I need to add it there
16 replies
DTDrizzle Team
Created by 26thavenue on 1/4/2024 in #help
Error using the query param
export const cloudflare: Handle = async ({ event, resolve }) => {
if (dev) {
event.locals.D1 = drizzle(connectD1('D1', { hostname }), { schema });
} else if (event?.platform?.env && !dev) {
event.locals.D1 = drizzle(event.platform?.env?.D1, { schema });
}
return await resolve(event);
};
export const cloudflare: Handle = async ({ event, resolve }) => {
if (dev) {
event.locals.D1 = drizzle(connectD1('D1', { hostname }), { schema });
} else if (event?.platform?.env && !dev) {
event.locals.D1 = drizzle(event.platform?.env?.D1, { schema });
}
return await resolve(event);
};
This is in one of the sequences in hooks.server.ts in sveltekit event.locals.D1 is defined in my app.d.ts file under Platform and Locals interface Defined as D1: DrizzleD1Database;
16 replies
DTDrizzle Team
Created by 26thavenue on 1/4/2024 in #help
Error using the query param
You mean what I export from $lib/db/schema?
16 replies
DTDrizzle Team
Created by 26thavenue on 1/4/2024 in #help
Error using the query param
@Angelelz, I am seeing many posts of this for some reason.
import * as schema from '$lib/db/schema';
import { connectD1 } from 'wrangler-proxy';

export const cloudflare: Handle = async ({ event, resolve }) => {
if (dev) {
event.locals.D1 = drizzle(connectD1('D1', { hostname }), { schema });
} else if (event?.platform?.env && !dev) {
event.locals.D1 = drizzle(event.platform?.env?.D1, { schema });
}
return await resolve(event);
};

export const users = createTable('user', {
id: text('id')
.notNull()
.$defaultFn(() => uuidv4())
.primaryKey(),
export const usersRelations = relations(users, ({ one }) => ({
applications: one(applications)
}));


const user = await db.query.users.findFirst({
where: eq(users.id, user_id)
});
import * as schema from '$lib/db/schema';
import { connectD1 } from 'wrangler-proxy';

export const cloudflare: Handle = async ({ event, resolve }) => {
if (dev) {
event.locals.D1 = drizzle(connectD1('D1', { hostname }), { schema });
} else if (event?.platform?.env && !dev) {
event.locals.D1 = drizzle(event.platform?.env?.D1, { schema });
}
return await resolve(event);
};

export const users = createTable('user', {
id: text('id')
.notNull()
.$defaultFn(() => uuidv4())
.primaryKey(),
export const usersRelations = relations(users, ({ one }) => ({
applications: one(applications)
}));


const user = await db.query.users.findFirst({
where: eq(users.id, user_id)
});
This is essentially my code. Importing the schema to drizzle, exporting a user and its relationship. For some reason vscode is complaining about this
Property 'users' does not exist on type 'DrizzleTypeError<"Seems like the schema generic is missing - did you forget to add it to your DB type?">'.ts(2339) any
This is not a big problem since the code work itself, it's just typescript that complains, but it would be nice to see that everything is properly setup 🤓
16 replies
DTDrizzle Team
Created by hexcowboy on 1/24/2024 in #help
not getting proper type inference on any queries
Hey I got the same issue, did you resolve this?
2 replies
CDCloudflare Developers
Created by sten on 2/5/2024 in #pages-help
How to serve javascript files (as third party lib)
That's sounds super simple! I'll definitely do that. Thanks @ScottF
3 replies