Tenkes
Tenkes
Explore posts from servers
DTDrizzle Team
Created by suljii on 1/8/2025 in #help
Cannot read properties of undefined (reading 'findMany')
and then whenever you define new tables to that file it will already be passed to drizzle(), since it's taking everything from that file
31 replies
DTDrizzle Team
Created by suljii on 1/8/2025 in #help
Cannot read properties of undefined (reading 'findMany')
but it's simpler to import everything from your schema file and name it schema, so you can pass that to your drizzle(). just like I did in code snippet I sent from my project
31 replies
DTDrizzle Team
Created by suljii on 1/8/2025 in #help
Cannot read properties of undefined (reading 'findMany')
it can also be
const { accounts } = require('../../../db/schema')

const db = drizzle(database_url, {
schema: {
accounts
}
})
const { accounts } = require('../../../db/schema')

const db = drizzle(database_url, {
schema: {
accounts
}
})
31 replies
DTDrizzle Team
Created by suljii on 1/8/2025 in #help
Cannot read properties of undefined (reading 'findMany')
same like you did
31 replies
DTDrizzle Team
Created by suljii on 1/8/2025 in #help
Cannot read properties of undefined (reading 'findMany')
I believe this is required if you want to use db.query
31 replies
DTDrizzle Team
Created by suljii on 1/8/2025 in #help
Cannot read properties of undefined (reading 'findMany')
Oh I think you need to define schema in your drizzle connection. Here's code snipped from my project:
import { Pool, neonConfig } from '@neondatabase/serverless'
import { drizzle } from 'drizzle-orm/neon-serverless'
import * as schema from './schema' // <- importing schema

const pool = new Pool({ connectionString: process.env.DATABASE_URL })

export const db = drizzle({ client: pool, schema }) // passing schema to drizzle connection
import { Pool, neonConfig } from '@neondatabase/serverless'
import { drizzle } from 'drizzle-orm/neon-serverless'
import * as schema from './schema' // <- importing schema

const pool = new Pool({ connectionString: process.env.DATABASE_URL })

export const db = drizzle({ client: pool, schema }) // passing schema to drizzle connection
31 replies
DTDrizzle Team
Created by suljii on 1/8/2025 in #help
Cannot read properties of undefined (reading 'findMany')
module.exports { accounts }
module.exports { accounts }
should be
module.exports = { accounts }
module.exports = { accounts }
31 replies
DTDrizzle Team
Created by Andreas on 1/2/2025 in #help
Cannot read properties of undefined (reading 'referencedTable') for many-to-many
That really sucks, hope you at least figured it out
18 replies
DTDrizzle Team
Created by Andreas on 1/2/2025 in #help
Cannot read properties of undefined (reading 'referencedTable') for many-to-many
Or try to reset stuff, clear cache, generate and migrate db etc...
18 replies
DTDrizzle Team
Created by Andreas on 1/2/2025 in #help
Cannot read properties of undefined (reading 'referencedTable') for many-to-many
Doesn't make sense lol, it should work. Try to run it in drizzle.run and see what you get
18 replies
DTDrizzle Team
Created by Andreas on 1/2/2025 in #help
Cannot read properties of undefined (reading 'referencedTable') for many-to-many
Yeah that might be it. Or more precisely it might be because in your barrel file you're renaming default to user instead of users:
// 👇
export { default as user, usersRelations } from "./user";
// 👇
export { default as user, usersRelations } from "./user";
Same for teams. So either rename it or do what I said in previous message (I think it would be cleaner that way)
18 replies
DTDrizzle Team
Created by Andreas on 1/2/2025 in #help
Cannot read properties of undefined (reading 'referencedTable') for many-to-many
@Andreas
18 replies
DTDrizzle Team
Created by Andreas on 1/2/2025 in #help
Cannot read properties of undefined (reading 'referencedTable') for many-to-many
Interesting, everything looks good... I'm only skeptical about the way you're exporting from your barrel file and about the fact you're default-exporting your tables when you're already exporting them. Maybe remove export default from all your schema files and then your barrel file should look something like:
export { users, usersRelations } from "./user";
export { teams, teamsRelations } from "./team";
export { usersToTeams, usersToTeamsRelations } from "./usersToTeams";
export { users, usersRelations } from "./user";
export { teams, teamsRelations } from "./team";
export { usersToTeams, usersToTeamsRelations } from "./usersToTeams";
18 replies
DTDrizzle Team
Created by Andreas on 1/2/2025 in #help
Cannot read properties of undefined (reading 'referencedTable') for many-to-many
ans then when you want to loop through them you would do:
user.usersToTeams.map(({ user }) => console.log(user.id))
user.usersToTeams.map(({ user }) => console.log(user.id))
18 replies
DTDrizzle Team
Created by Andreas on 1/2/2025 in #help
Cannot read properties of undefined (reading 'referencedTable') for many-to-many
db.query.teams.findMany({
with: {
usersToTeams: {
with: {
users: true // <- this should be user not users
}
}
}
})
db.query.teams.findMany({
with: {
usersToTeams: {
with: {
users: true // <- this should be user not users
}
}
}
})
18 replies
DTDrizzle Team
Created by Andreas on 1/2/2025 in #help
Cannot read properties of undefined (reading 'referencedTable') for many-to-many
(ping me when you reply)
18 replies
DTDrizzle Team
Created by Andreas on 1/2/2025 in #help
Cannot read properties of undefined (reading 'referencedTable') for many-to-many
Can you send files where you defined tables and relations? These files to be specific:
export { default as user, usersRelations } from "./user"; // <-
export { default as team, teamsRelations } from "./team"; // <-
export { default as usersToTeams, usersToTeamsRelations } from "./usersToTeams"; // <-
export { default as user, usersRelations } from "./user"; // <-
export { default as team, teamsRelations } from "./team"; // <-
export { default as usersToTeams, usersToTeamsRelations } from "./usersToTeams"; // <-
18 replies
DTDrizzle Team
Created by Tenkes on 9/22/2024 in #help
PostgresError: foreign key constraint "product_categories_category_id_fk" cannot be implemented
wdym?
14 replies
DTDrizzle Team
Created by Tenkes on 9/22/2024 in #help
PostgresError: foreign key constraint "product_categories_category_id_fk" cannot be implemented
I can't add { onDelete: 'cascade' } if I'm using relations?
14 replies
DTDrizzle Team
Created by Tenkes on 9/22/2024 in #help
PostgresError: foreign key constraint "product_categories_category_id_fk" cannot be implemented
omg that's just amazing.. THANKS!
14 replies