- 是一个基于分布式文件存储的数据库;介于关系型数据库和非关系型数据库之间
- 存储的是BSON(Binary JSON)


在nodejs中使用,可以使用promise/async await的形式 ```javascript const MongoClient = require(‘mongodb’).MongoClient; const url = “mongodb://42.192.130.44:27017/“; // url 是数据库地址 MongoClient.connect(url).then(coon => { console.log(‘数据库已经链接’); // db()内是数据库名 // collection()内是表名 const test = coon.db(‘load’).collection(‘testData’); test.insertOne({‘site’: ‘test-data.com’}).then(res => { return test.find().toArray().then(arr => {
console.log(arr);
}) }).then(res => { return test.updateMany({ “site”: “runoob.com” }, { $set: { “site”: “example.com” } }) }).then(res => { return test.find().toArray().then(arr => {
console.log(arr);
}) }).then(() => { return test.deleteMany({site: ‘https://www.google.com'}); }).then(res => { return test.find().toArray().then(arr => {
console.log(arr);
}) }).catch(err => { console.log(‘数据操作失败’ + err.message); }).finally(()=> { coon.close() })
}).catch(err => { console.log(‘数据库连接失败’);
}) ```
