If you need to persist data using now
, it’s recommended that you use a hosted database service. In this lesson we'll create a new, free MongoDB database on http://mlab.com and wire it up to use with our node.js app running on Zeit's now
hosting service.
You could also use a docker container to spin up your app with any database you want, right?
No, absolutely not! You have no control over the instance(s) where your app runs. Other than a small temp folder you cannot assume persistence of any file system writes, which means your database can and will fragment when autoscaling!
@mykola Is there a way to use .env
? I believe on the zeit Slack I have seen the use of dotenv
by having something like
cp dev.env .env && now && rm .env
or something along those lines. Has that improved?
Thanks!
That's a great question, I'll see if I can dig something up. I believe your package.json file can define now.env
and have the keys -> values there be exported automagically, but obviously only do and commit this to your repo if you're using now
secrets via @secretname
as your values.
Hi there, your example is based on the mlab service. Would it be possible to do the same thing with Mongodb Atlas? Thanks