Using Drizzle/Mongoose directly

default discord avatar
jasonaa10 months ago
10

If I use Payload CMS, I get a admin interface, GraphQL and REST APIs for free, migrations handled, etc.



Can I still use Drizzle or Mongoose directly to update data, or do I need to exclusively use Payload's tooling for changes? I think this is the case but wanted to be sure.

  • discord user avatar
    alessiogr
    10 months ago

    Absolutely you can! Drizzle and Mongoose is fully exposed by payload - you can find it inside of

    payload.db
  • default discord avatar
    jasonaa10 months ago

    thanks, looking forward to playing with payload!

  • default discord avatar
    techinverted7 months ago

    @Alessio🍣 Would it be faster using payload.db to update or create data ?

  • discord user avatar
    alessiogr
    7 months ago

    payload.db is faster, but it lacks support for lots of things like access control and hooks. It's basically a direct database call with very little payload other than where queries and pagination

  • default discord avatar
    techinverted7 months ago

    Okay makes sense. It’s exactly what I was looking for



    @Alessio🍣 I had another question, if I run payload in a nodejs cluster is there anything I need to keep in mind or best practices?

  • default discord avatar
    ssyberg6 months ago

    Did you end up trying this? If so how did you configure it?

  • default discord avatar
    techinverted6 months ago

    @seth It’s quite simple. You can use payload.db anywhere you need with the local api.



    I’ll try and find you an example when I get back



    Oh wait, are you referencing the cluster setup? I did set it up



    I used pm2 to create a cluster, I’ve also implemented on railway using their cluster implementation (replicas)

  • default discord avatar
    ssyberg6 months ago

    So I actually had a huge performance boost just spawning multiple workers in

    server.ts

    I saw a 3-4x increase overall without using PM2!

  • default discord avatar
    techinverted6 months ago

    Ooh nice @seth , I’ve done that as well. I use them for intensive cronjobs. What are you using for workers to do ?

  • default discord avatar
    ssyberg6 months ago

    Just serving lots of web requests!

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.