- Need for persistence
- Persistence in the real world
- Persistence in computers
- In memory
- Text/JSON/binary files
- Databases
- Types of databases
- NoSql database
- Server > Databases > Collections > Documents
- Collections
- Interfacing with the database
- Command line/shell
- API/driver
- Commands
show dbs
use <db>
# read
db.<collection>.find({"email": "jack@belly.com" })
db.<collection>.findOne({"profile.name": "Jack Belly" })
# write
db.createCollection('collectionName')
db.<collection>.insertOne({...})
db.<collection>.updateOne({...})
db.<collection>.deleteOne({...})
_id
field is automatically created and indexed
- Using MongoDb in NodeJS
mongodb
package
- Creating a connection
- Closing a connection