提问者:小点点

是否有任何允许使用猫鼬驱动程序API的Node. js嵌入式数据库?


我想在我的Web应用程序中使用mongoose驱动程序API,但我也想为我的应用程序提供一个嵌入式数据库。我不想在服务器中安装mongodb。有没有允许使用mongoose驱动程序和MongoDB API的node. js嵌入式数据库?

我找到了NeDB,但它似乎不允许使用猫鼬。


共1个答案

匿名用户

您可以使用云数据库,例如https://cloud.mongodb.com/

有了这个代码

 const MongoClient = require('mongodb').MongoClient;
const uri = "mongodb+srv://<username>:<password>@<suburl>.mongodb.net/<dbname>?retryWrites=true&w=majority";
const client = new MongoClient(uri, { useNewUrlParser: true });
client.connect(err => {
  const collection = client.db("test").collection("devices");
  // perform actions on the collection object
  client.close();
});