The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

Use a hosted database with Zeit’s Now

Use a hosted database with Zeit’s Now

10:50
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.
Watch this lesson now
Avatar
egghead.io

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.

Avatar
Jacek

You could also use a docker container to spin up your app with any database you want, right?

Avatar
mykola

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!

In reply to Jacek
Avatar
Michael

@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!

Avatar
mykola

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.

In reply to Michael
Avatar
Jean-Marc

Hi there, your example is based on the mlab service. Would it be possible to do the same thing with Mongodb Atlas? Thanks

HEY, QUICK QUESTION!
Joel's Head
Why are we asking?