self reference error

I have just started to learn drizzle and was stuck on some problem and I get this error => 'users' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.ts(7022) const users: any also when i query my db why do I not get type completions on the returned object.
12 Replies
Jsx
Jsx13mo ago
You are getting this error while quering??
Izaan
IzaanOP13mo ago
No no its in the schema I have anothe table channel and when i reference it in user it gives the same error
Jsx
Jsx13mo ago
can you share complete schema file then only I will be able to figure out Btw why are you referencing adminId as users.id?? Last 4th line I think you mean to reference id of admin table??
Izaan
IzaanOP13mo ago
Heres the schema
No description
Izaan
IzaanOP13mo ago
The schema
No description
Izaan
IzaanOP13mo ago
what I want the user to have two roles if the user is admin he will have multiple editor users and every editor user will have one admin user. Then I thought why not channel table have this logic contained ie the channel will have users as editor and one user as admin. If you have any suggestions in this regard I will be glad to see it
Jsx
Jsx13mo ago
all imports are from drizzle-orm/pg-core right? Can you check
Izaan
IzaanOP13mo ago
yup import { timestamp, pgTable, primaryKey, text } from "drizzle-orm/pg-core"; import type { AdapterAccount } from "@auth/core/adapters"; import { relations } from "drizzle-orm";
Jsx
Jsx13mo ago
Okay I reconstructed the schema and I am not getting any error Versions "drizzle-orm": "^0.29.0", "drizzle-kit": "^0.20.4", "pg": "^8.11.3", Even for 0.29.1 it's working fine
Izaan
IzaanOP13mo ago
I have postgres as core dependency and pg as dev depdency well pg is not needed I was getting some errors saying pg is missing when I was pushing the migrations so I added it as dev dep
Jsx
Jsx13mo ago
pg is required for runtime don't add it as dev dep You need it for client
Izaan
IzaanOP13mo ago
I did channelId: text("channelId").references( (): AnyPgColumn => youtubeChannels.id, { onDelete: "cascade", } ), and it fixed the error
Want results from more Discord servers?
Add your server