Open rkrishnasanka opened 4 months ago
I would appreciate a PR on this, or other documentation improvements in general.
@rkrishnasanka Simply call bob.New(db)
Yeah I figured it out shortly after commenting. I missed the link for bob executors. I'll do a PR once I'm done implementing stuff.
Is there a discord for this ? I feel like its better to get some direct feedback. The query parameters are confusing. For example:
queuesView := psql.NewView[*models.Queue]("core", "queues")
// Check if the queue already exists
row, err := queuesView.Query(
context.Background(),
bob.NewDB(db),
models.SelectWhere.Queues.QueueName.EQ(queuename),
).One()
In this scenario, I get:
"pq: missing FROM-clause entry for table \"queues\"" bob golang
as the error
If you are using the code generation, the view/table is already created for you.
Simply use:
queue, err := models.Queues.Query(
context.Background(),
bob.NewDB(db),
models.SelectWhere.Queues.QueueName.EQ(queuename),
).One()
//queue is of type models.Queues now
@jacobmolby So turns out that there are a couple more errors happening here that made this complicated #187 . so thats why I've just been dealing with bugs.
@rkrishnasanka I couldn't find any documentationion of how to use the CLI to generate the code, could you maybe share how you did it?
Here's the command I use
go run github.com/stephenafamo/bob/gen/bobgen-psql@latest -c ./config/bobgen.yaml
Here's the config
psql:
dsn: "postgres://postgres:@localhost:5432/postgres?sslmode=disable"
schemas: ["application","core"]
shared_schema: "public"
It would be great if there was a full example for: