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      
  },
});

According to docs. ^^^

I have drizzle. config.ts like this already :
typescript 
export default defineConfig({
  schema: './drizzle/schemas/*.ts',
  out: './drizzle/migrations',
  dialect: 'postgresql',
}
)



Why cant I just do
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?
Was this page helpful?