-1
我有簡單的Mongodb集合db_userProfile
。在收集架構中有:如何從MongoDB中將值提取到JavaScript中?
native_language: {
type: String,
}
如何提取字符串值並將其放入JavaScript變量中?
我有簡單的Mongodb集合db_userProfile
。在收集架構中有:如何從MongoDB中將值提取到JavaScript中?
native_language: {
type: String,
}
如何提取字符串值並將其放入JavaScript變量中?
你提到的JavaScript,所以我想你使用Node.js的 下面是一個例子,如何能與node.js的
MongoDB的驅動程序achived// Retrieve
var MongoClient = require('mongodb').MongoClient;
// Connect to the db
MongoClient.connect("mongodb://localhost:27017/exampleDb", function(err, db) {
if(err) { return console.dir(err); }
var collection = db.collection('db_userProfile');
collection.find().toArray(function(err, items) {
//items is JavaScript variable that contains data from mongodb collection
});
});
更多Infor正在here
你也可以使用mongoosejs
類似db_userProfile.native_language應該足夠了。如果它不起作用,請用數據發佈對象 – eloleon