即使在添加本机承诺之后,这仍是在保存时仍会抛出的错误。
(node:5604)DeprecationWarning:不推荐使用Mongoose:mpromise(mongoose的默认承诺库),而是插入自己的promise库:http://mongoosejs.com/docs/promises.html
mongoose.Promise = global.Promise;
mongoose.connect('mongodb://127.0.0.1/optimusCP')
.then(function () {
console.log('Connected to MONGOD !!');
}).catch(function (err) {
console.log('Failed to establish connection with MONGOD !!');
console.log(err.message);
});
我试过蓝鸟和蓝鸟q,仍然没有找到解决方案。 下面是我保存时的代码,显示以下弃用警告..
var user = new User();
user.email = req.body.email;
user.password = hash;
user.save()
.then(function (user) {
console.log(user);
})
.catch(function (err) {
console.log(err);
});
这个错误发生在mongoose的新版本4.8.1,但在4.7.6 mongoose版本上运行正常。
答案 0 :(得分:4)
尽管在 Dim objTableLogonInfo As CrystalDecisions.Shared.TableLogOnInfo
'\ Report objects
Dim objDatabaseTable As CrystalDecisions.CrystalReports.Engine.Table
Dim objCrSection As CrystalDecisions.CrystalReports.Engine.Section
Dim objCrReportObject As CrystalDecisions.CrystalReports.Engine.ReportObject
Dim objCrSubreportObject As CrystalDecisions.CrystalReports.Engine.SubreportObject
Dim objCrSubreport As CrystalDecisions.CrystalReports.Engine.ReportDocument
'\ Call you code to get the connection info from the INI or txt file
objTableLogonInfo = New CrystalDecisions.Shared.TableLogOnInfo
objTableLogonInfo.ConnectionInfo.UserID = "UserID " ' UserIDFromFile
objTableLogonInfo.ConnectionInfo.Password = "Password " ' PasswordFromFile
objTableLogonInfo.ConnectionInfo.ServerName = "ServerName " ' ServerNameFromFile
objTableLogonInfo.ConnectionInfo.DatabaseName = "DatabaseName " ' DatabaseNameFromFile
'\ Loop through the tables in the database and set the connection properties of each
For Each objDatabaseTable In pCrystalReport.Database.Tables
objDatabaseTable.ApplyLogOnInfo(objTableLogonInfo)
Next objDatabaseTable
'\ Now do the same for the subreports(if any)
'\ Loop through the sections in the report
For Each objCrSection In pCrystalReport.ReportDefinition.Sections
'\ Loop through the collection
For Each objCrReportObject In objCrSection.ReportObjects
'\ If the report object is a subreport
If objCrReportObject.Kind = CrystalDecisions.Shared.ReportObjectKind.SubreportObject Then
'\ Get a reference to it
objCrSubreportObject = objCrReportObject
'\ Open it
objCrSubreport = objCrSubreportObject.OpenSubreport(objCrSubreportObject.SubreportName)
'\ Set logon info for each table in the subreport
For Each objDatabaseTable In objCrSubreport.Database.Tables
objDatabaseTable.ApplyLogOnInfo(objTableLogonInfo)
Next objDatabaseTable
End If
Next objCrReportObject
Next objCrSection
End Sub
之前使用mongoose.Promise = global.Promise;
,但我也有同样的警告。
我发现,我在一个文件中初始化了mongoose连接:
mongoose.connect(...)
但是我也在另一个文件中引入了import mongoose from 'mongoose';
...
// Connect to MongoDB
mongoose.Promise = global.Promise;
mongoose.connect(mongoUri, mongoOptions);
mongoose.connection.on('error', (err) => {
console.error(`MongoDB connection error: ${err}`);
process.exit(1);
});
(描述了mongoose方案),所以我在第二个文件中添加了mongoose
,因此警告消失了。
mongoose.Promise = global.Promise;
可能你也有同样的情况。
答案 1 :(得分:0)
我用这个
成功摆脱了这个消息int row = 0 , column = 0;
if(inputFile.hasNextInt())
row= inputFile.nextInt();
if(inputFile.hasNextInt())
column = inputFile.nextInt();
int [][] array=new int [row][column];
System.out.println("This array has "+row+" rows and "+column+" columns");
for (int i=0;i<row; i++){
for (int j=0; j<column; j++){
if(inputFile.hasNextInt())
array[i][j] = inputFile.nextInt();
System.out.println(array[i][j]);
}
}
答案 2 :(得分:0)
我使用bluebird来使用mongoose模型函数node v6.9.4:
的promisemongoose.Promise = require('bluebird');
答案 3 :(得分:0)
我和Mongoose 4.8.1有同样的问题,更新到4.9.1解决了我的问题。