Recommendations for MongoDB Driver and Schema solutions?

@hyliancoder welcome to Redwood! Admittedly, my enthusiasm for this has not correlated with time and effort. I think a POC is valuable and would get a lot of community interest/feedback/attention. So if you’re interested, I’d be very happy to help as I can!

The main reason for attempting a specific integration is that Redwood uses Prisma for the DB connection/query/migration layer. It’s not required, but it sure is handy. Prisma2 was released earlier this year and so far only supports SQL-based DBs. MongoDB is coming. However, my guess is that we won’t see it until mid-2021.

If you haven’t yet, do take a look at the Redwood Tutorial — especially the “Getting Dynamic” section.

Next up would be looking at some examples of other Redwood DB integrations that don’t use Prisma:

  • This is a (very early) example with Neo4j
  • More recent example with FuanaDB

Sketching out an implementation:

  • Redwood currently instantiates the Prisma Client in api/src/lib/db.js It makes sense to use this for MongoDB client setup
  • In the near-term, we’ll be renaming api/prisma as api/db. Makes sense do use that directory structure for this as well and have schema related files in that directory
  • I’m partial to attempting the native Mongo driver. But if you’re familiar with Mongoose, that makes sense to try first
  • Ideally, there would be a nice “local dev setup” and seamless deploy. But, again, for a POC you could just connect to something like Atlas and not worry about the local setup.
  • Lastly, Redwood :heart:making use of the CLI for workflow, e.g. rw db save... up... seed. I don’t think a POC needs to include going this far, but it might be interesting to consider what the workflow might/could be and, if applicable, add some package.json scripts.
    • note: if you do want to try things like the Mongo native schema solution, this type of CLI/Script workflow could come in handy

Thoughts/questions/interested??

1 Like