Jay
Jay
Explore posts from servers
DTDrizzle Team
Created by Jay on 6/22/2024 in #help
Custom fields of db.query for many to many relationship for FE
No description
1 replies
DTDrizzle Team
Created by Jay on 6/12/2024 in #help
Multiple files schemas with query to Access data
I want to use query but I heard you have to import every schemas to use query. Is there a way to import every files in that folder instead of doing this below:

import * as schema1 from './schema1';
import * as schema2 from './schema2';
import { drizzle } from 'drizzle-orm/...';
const db = drizzle(client, { schema: { ...schema1, ...schema2 } });
const result = await db.query.users.findMany({
with: {
posts: true
},
});

import * as schema1 from './schema1';
import * as schema2 from './schema2';
import { drizzle } from 'drizzle-orm/...';
const db = drizzle(client, { schema: { ...schema1, ...schema2 } });
const result = await db.query.users.findMany({
with: {
posts: true
},
});
According to docs. ^^^ I have drizzle. config.ts like this already :
typescript
export default defineConfig({
schema: './drizzle/schemas/*.ts',
out: './drizzle/migrations',
dialect: 'postgresql',
}
)
typescript
export default defineConfig({
schema: './drizzle/schemas/*.ts',
out: './drizzle/migrations',
dialect: 'postgresql',
}
)
Why cant I just do
const db = drizzle(client)
const db = drizzle(client)
(basically, this wont work anymore without {schema} so I cant do db.query.user) instead of importing every schemas with specific file name any way to do this?
2 replies