Unable to connect to DB
Thank God there is a Discord server xD
I been trying to make this work for like 2 hours and I can't get it to work
Solution:Jump to solution
There are a few approaches:
https://kysely.dev/docs/recipes/schemas
1. WithSchemaPlugin to apply schema globally to all queries.
2. withSchema method to apply to specific queries on the fly....
Working with schemas | Kysely
First of all, when we talk about schemas in this document, we mean custom
22 Replies
Hey 👋
What errors are you getting?
my db variable returns an empty object
so all the functions I run on it don't work cuz it's an empty object that doesn't contain those functions
for example,
selectFrom
its a class instance, without toString, toJSON, etc. implementation and no regard for enumarable keys. It doesn't mean the functions don't exist on it when you print it 🙂
ok
my knowledge isn't too vast so excuse me if its an easy fix
All good, we all learn each day
xD
this shouldn't work. it's not kysely code. Also Kysely has an introspection module that returns all tables.
the reason I had this code was because I keep getting the error that
https://kysely-org.github.io/kysely/classes/Kysely.html#introspection this exists on db and has functionality to get all tables metadata
Kysely | kysely
Documentation for kysely
I keep getting this error
this is a TRPC error
oops
one second
I noticed a small mistake
this is my TRPC endpoint code
I am making the api call using TRPC but it's this function that isn't running
relation User does not exist means that table is not in your database
right, but I do have it in my db
and that is why I was trying to retrieve all my tables to understand what Kysely sees
but I will take a look at the link you sent, thank you for the help, hope you don't mind if I come back with further questions
Its all good, happy to answer
look at your Pool config, verify its the right database instance. verify User table is in the default postgres schema, if not you need to add schema prefix when refering to it or use
.withSchema
its in the default Postgres Schema
I think I need to do .withSchema and usue "barber"
does
.withSchema()
go on the Pool instance?https://kysely-org.github.io/kysely/classes/WithSchemaPlugin.html found this gonna take a loook
WithSchemaPlugin | kysely
Documentation for kysely
thank you very much @Igal
if not you need to add schema prefix
where would I add this
in here database:'Barbercate\schema=barbe
' rather have it default to that schema instead of using .withSchema() within my functions
beautiful, thank you again!Solution
There are a few approaches:
https://kysely.dev/docs/recipes/schemas
1. WithSchemaPlugin to apply schema globally to all queries.
2. withSchema method to apply to specific queries on the fly.
3. naming the tables
schema.table
in Database
interface.Working with schemas | Kysely
First of all, when we talk about schemas in this document, we mean custom