redwoodjs-com-archive icon indicating copy to clipboard operation
redwoodjs-com-archive copied to clipboard

MongoDB: create a doc or cookbook

Open thedavidprice opened this issue 4 years ago • 11 comments

Prisma supports MongoDB. And in a simple POC I was able to easily migrate the Tutorial blog project from Postgres to Mongo with very little changes required.

  • Generators work with MongoDB 🚀
  • What will change with deployment? (I.e. no longer a need for prisma migrations, correct?)
  • ?

thedavidprice avatar Oct 14 '21 14:10 thedavidprice

I don't have much extra bandwidth right now to take on more projects, but I've done a decent amount of work on this over the last year so happy to help out and provide notes or guidance if anyone wants to take this on.

Relevant Links

TODOS

  • Docs like these for using Mongo locally instead of Postgres
  • Unit tests and mocks/scenarios, check testing the database section of docs

ajcwebdev avatar Oct 14 '21 17:10 ajcwebdev

@ajcwebdev Happy to work with you on this. I've had some experience with Mongo.

barakcodes avatar Oct 14 '21 17:10 barakcodes

@barakcodes that's awesome to hear!

Prisma has done a fantastic job with their MongoDB docs so we should also be heavily referencing those and making sure we stay up to date with the current capabilities. For example, Prisma v3.2 added Preview support for introspection.

Other upcoming features

Prisma Videos

For a quick and easy win I'd check out the video Prisma created for installing Mongo locally and create a doc based on that.

ajcwebdev avatar Oct 14 '21 17:10 ajcwebdev

Thanks! A pretty detailed guide, I'll get hacking on this weekend.

barakcodes avatar Oct 15 '21 06:10 barakcodes

@ajcwebdev Started on this, it seems the only way that I could find to get Mongo to work with serverless is using Mongo Atlas. Seem to be some limitations including migrations in comparison, I'm thinking I should specifically point these out in the docs. Maybe like a little section at the end. What do you think?

barakcodes avatar Oct 30 '21 22:10 barakcodes

Yeah definitely, there's an open issue right now about migration support that you can link to, so Prisma is aware and is working on support.

ajcwebdev avatar Oct 30 '21 22:10 ajcwebdev

Yeah definitely, there's an open issue right now about migration support that you can link to, so Prisma is aware and is working on support.

Thanks! @ajcwebdev I'll get on with it, then we can have a draft PR, then probably move to the production guide then finish with the testing section. How does that sound?

barakcodes avatar Oct 30 '21 22:10 barakcodes

Yeah that sounds great, feel free to provide any pieces as they're ready to go and I will keep an eye out and provide notes 👍!

ajcwebdev avatar Oct 30 '21 22:10 ajcwebdev

Word from the Prisma team is that migrations will not be supported in the near future, but you can use db push as a workaround for now.

ajcwebdev avatar Nov 01 '21 20:11 ajcwebdev

Quick update on this front, I've got a guide now on Getting Started with MongoDB on Railway. I'm too much of a MongoDB noob to know why this is the case, but there's some important differences in what connection string you need to give the Prisma schema.

Atlas Version

Append connection string with ?retryWrites=true&w=majority.

mongodb+srv://ajcwebdev:<PASSWORD>@posts.5mngs.mongodb.net/myFirstDatabase?retryWrites=true&w=majority

Railway Version

Append connection string with ?authSource=admin.

mongodb://mongo:<PASSWORD>@containers-us-west-1.railway.app:6852/test?authSource=admin

@thedavidprice and @dthyresson, given the current options what are your opinions on how to build out the cookbook in terms of the actual database deployment step? Should it include instructions for:

A. Only Atlas B. Only Railway C. Separate sections with instructions for each

ajcwebdev avatar Mar 06 '22 06:03 ajcwebdev

MongoDB is now Generally Available as of Prisma v3.12.0 🥳 🎉

ajcwebdev avatar Apr 05 '22 16:04 ajcwebdev