javascript Mongo DB

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript Mongo DB相关的知识,希望对你有一定的参考价值。

INSTALL MONGO DB

1. sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
2. echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
3. sudo apt-get update

  Install & Verify
4. sudo apt-get install -y mongodb-org
5. sudo nano /etc/systemd/system/mongodb.service

      Paste in the following contents, then save and close the file.
[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target

[Service]
User=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf

[Install]
WantedBy=multi-user.target


6. sudo systemctl start mongodb
7. sudo systemctl status mongodb

  Startup
8. sudo systemctl enable mongodb 


CREATE DB

MongoClient = require('mongodb').MongoClient;
var url = "mongodb://localhost:27017/mydb";

MongoClient.connect(url, function(err, db) {
  if (err) throw err;
  console.log("Database created!");
  db.close();
});


以上是关于javascript Mongo DB的主要内容,如果未能解决你的问题,请参考以下文章

javascript Mongo DB

javascript 用户存储库Mongo db adapter factory

如何将所有 Meteor Mongo 集合名称检索为 Javascript 数组?

mongo

mongo源码学习db.cpp之mongoDbMain方法分析

为啥 mongodb-native 驱动程序中有单独的 mongo.Server 和 mongo.Db?