SE-2840 Dr. Mark L. Hornick1 MongoDB A persistent data store
What is a database? Like a file, a database is used to persistently store information outside of an application The app can stop or crash, but the data persists and is still available after restart Unlike a file, a database is structured, allowing for easy manipulation (CRUD) Create Read Update Delete SE-2840 Dr. Mark L. Hornick2
MongoDB stores data JSON db.restaurants.insert( { "address" : { "street" : "2 Avenue", "zipcode" : "10075", "building" : "1480", "coord" : [ , ], }, "borough" : "Manhattan", "cuisine" : "Italian", "grades" : [ { "date" : " ", "grade" : "A"}, { "date" : " ", "grade" : "B"} ], "name" : "Vella } ); SE-2840 Dr. Mark L. Hornick3
MongoDB stores data JSON var restaurant = { "address" : { "street" : "2 Avenue", "zipcode" : "10075", "building" : "1480", "coord" : [ , ], }, "borough" : "Manhattan", "cuisine" : "Italian", "grades" : [ { "date" : " ", "grade" : "A"}, { "date" : " ", "grade" : "B"} ], "name" : "Vella }; db.restaurants.insert( restaurant ); SE-2840 Dr. Mark L. Hornick4
Once stored, data can be retrieved through various queries var favorites = db.restaurants.find( {“borough”:”Manhattan”); // favorites is a JSON array of ALL restaurants // in Manhattan SE-2840 Dr. Mark L. Hornick5