我正在尝试使用以下代码将数据插入mongoDb,但它没有显示任何错误或成功,
方式
function writeToDB(infoObject) {
dbService.connectDb(config.DB_CONFIG.CONNECTIONSTRING, {}).then(() => {
console.log("got the config for mongo");
dbService.insert(infoModel, infoObject)
})
.then(data => dbService.disconnectDb(data))
.then(data => console.log("success"))
.catch((error) => {
dbService.disconnectDb(error).then(error => {
console.log(error);
})
});
}
dbService
insert: function (model, object) {
return dbHelper.insert(model, object);
},
dbHelper
insert: function (model, doc) {
console.log("came insid the mongodb helper");
return new Promise(function (resolve, reject) {
model.create(doc, function (error, data) {
if (error)
reject(error);
resolve(data);
})
})
}
这是调用part的方法,
uploadInfoObject = {
ProcessID: context.invokeid,
Type: "Image",
ModifiedDate: new Date(),
Status: "Started",
Message: "Done"
};
writeToDB(uploadInfoObject);