A Mongo and A Mongoose

Last week we covered databases! Super exciting, right? It only makes sense, though, that the majority of back end development would be storing, accessing, and updating data. There are quite a few tools available for Node.js and the ones we covered are Mongo and Mongoose. Mongo or MongoDB itself stores data flexibly. Why does that flexibility matter? It is perfect for sets of data that are incomplete. If I had a list of contacts I wanted to store but I didn't have everyone's emails it wouldn't be a big deal - those email addresses would just be empty.

Mongo stores the data and Mongoose is a tool that accesses it for you. This is the secure way to retrieve data and validate it rather than having potentially sensitive information stored right in the code for anyone to see. Mongoose is pretty straightforward to use and I implemented it into my robots database (that thing again!). In a nutshell, I was able to swap out the database I had stored in a file and put it into Mongo on my computer. I then used Mongoose to access that data and use it in my code!



The page itself looks the same but the code is a bit different: https://github.com/victoriarainc/robotDirectoryMongo

Comments