前言:
- what is MONGO?
It is commonly used in combination with Node. Mongo is a document database, which we can use to store and retrive complex data from.
- Why use a database instead of just saving to a file
- Databases can handle large amount of data efficiently and store it compactly
- They provide tools for easy insertion, querying, and updating of data
- They generally offer security features and control over access to data
- They (generally) scale well
- SQL VS NOSQL
- SQL DATABASES: Structured Query Language databases are relational databases. We pre-define a schema of tables before we insert anything.
- NO-SQL DATAVASES: NoSQL databases do not use SQL. There are many types of no-sql database, including documents, key-value, and graph stores.
- Popular Databases
- why are we learning MANGO?
- Mongo is very commonly used with Node and Express(MEAN&MERN stacks)
- it's easy to get started with(through it can be tricky to truly master)
- It plays particularly well with JavaScript
- Its popularity also means there is a strong community of developers using Mongo.
- MongoDB下载安装步骤 : https://docs.mongodb.com/manual/installation/
- 在官网https://brew.sh/#install install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
2. brew tap mongodb/brew
3. brew install mongodb-community@4.4
4. brew services start mongodb-community@4.4
1,2,3,4都在terminal运行下载安装(MacOS)
- 在terminal输入mongo进入服务
- 输入help查看用法
- show dbs/ show collections/use <db_name>(如果db_name不是已经存在的话,新建一个)/db.dogs.find()