嗨,我使用以下代码将值插入到我的 mongodb
var mongoose = require('mongoose');
var db = mongoose.createConnection('mongodb://localhost/TruJuncSVC1');
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function callback () {
console.log('connection opened in Mongodb with SAMPLE TESTING Database')
var schema = new mongoose.Schema({Response: String,Id:String,Name:String,News:String,Details:String});
var SvcOrch = db.model('SvcOrch', schema);
var data = new SvcOrch({ 'Response': 'DailyLoad','Id':'S3000981','Name':'Stears','News':'Mens Boutiques Try New Tactics for Winning Loyal CustomersTradition Finds New Biz in Old Font','Details':'Stears Roebuck and Co. or Stears, is an American chain of department stores,[2] which was founded by Richard Warren Sears and Alvah Curtis Roebuck in the late 19th century. Formerly a component of the Dow Jones Industrial Average, Stears bought out Kmart[3] in early 2005, creating the Stears Holdings Corporation.'});
data.save(function (err) {
if (err) return handleError(err);
// saved!
console.log('\nResponse data saved in MongoDB')
})
});
});
我可以为每个属性插入一个值,我需要为单个属性保存多个值,比如 id 应该有 2 或 3 个值,所有属性都一样。任何关于如何继续进行的想法都会很有帮助。谢谢提前