Great series so far, awesome to see how your using cursor to help you code through this large project. As an experienced developer having used payload for the last year since 2.0 I have some advice that might help you out. I notice that your having cursor generate the drizzle schemas for the db in addition to the payload collection configs. This isn’t exactly what you want as the payload collection configs act as the db schemas. The payload team has created a robust db abstraction layer so if you’re using payload/postgres as the database adapter payload actually uses drizzle under the hood within the payload api. So generating the drizzles schemas is redundant. The proper flow is to call the payload generate:types command each time you make a collection config change and this will auto generate the typescript types, which will also help with those errors you see in the relationship field. Also as you’re using Postgres you’ll want to create the migrations as well using payload migration create command. Then onto the functions that call the database you want to use the payload local api instead of using the drizzle db.insert, db.select commands directly as this is also redundant and miss using payload for what it is. Instead you’ll want to use the local API from payload by calling payload.create({collection: “x”, data: {} }). Or payload.find() or payload.findbyId() this will use drizzle under the hood as you’ve setup the Postgres adapter in the payload config. I hope this helps, and can get on back on the right track before cursor takes you too far off.
thanks Sam for shaaring this tutorials and thanks for all the efforts
Great series so far, awesome to see how your using cursor to help you code through this large project.
As an experienced developer having used payload for the last year since 2.0 I have some advice that might help you out.
I notice that your having cursor generate the drizzle schemas for the db in addition to the payload collection configs. This isn’t exactly what you want as the payload collection configs act as the db schemas. The payload team has created a robust db abstraction layer so if you’re using payload/postgres as the database adapter payload actually uses drizzle under the hood within the payload api. So generating the drizzles schemas is redundant.
The proper flow is to call the payload generate:types command each time you make a collection config change and this will auto generate the typescript types, which will also help with those errors you see in the relationship field. Also as you’re using Postgres you’ll want to create the migrations as well using payload migration create command.
Then onto the functions that call the database you want to use the payload local api instead of using the drizzle db.insert, db.select commands directly as this is also redundant and miss using payload for what it is.
Instead you’ll want to use the local API from payload by calling payload.create({collection: “x”, data: {} }). Or payload.find() or payload.findbyId() this will use drizzle under the hood as you’ve setup the Postgres adapter in the payload config.
I hope this helps, and can get on back on the right track before cursor takes you too far off.
Thank you so much! This is great advice and I will certainly make some adjustments!
Hi sam the Github phase-3 not found
Thanks for catching that Alex! I've pushed the initial commit now and you should be able to access it now!