Skip to content

Commit

Permalink
Merge pull request #143 from dcalvoalonso/fix/Warnings
Browse files Browse the repository at this point in the history
Fix: removes warnings
  • Loading branch information
fgalan authored May 8, 2019
2 parents 0df241a + 5598358 commit eca9474
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix: removal of warnings and deprecation warnings
3 changes: 3 additions & 0 deletions lib/services/model/dbConn.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ function init(host, db, port, username, password, options, callback) {

logger.info(context, 'Attempting to connect to MongoDB instance. Attempt %d', retries);

options.useNewUrlParser = true;
options.useFindAndModify = false;
mongoose.set('useCreateIndex', true);
candidateDb = mongoose.createConnection(url, options, function(error, result) {
if (error) {
logger.error(context, 'MONGODB-001: Error trying to connect to MongoDB: %s', error);
Expand Down
2 changes: 1 addition & 1 deletion lib/services/server/mongodbDeviceRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ function register(object, callback) {
* Remove all the objects from the registry.
*/
function clean(callback) {
Device.model.remove({}, function(error, number) {
Device.model.deleteOne({}, function(error, number) {
if (error) {
callback(errors.InternalDbError(error));
} else {
Expand Down
4 changes: 2 additions & 2 deletions test/unit/server/device-registry-mongo-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('MongoDB Device registry', function() {
registerHandlers
], function (error, results) {
deviceLocation = results[2];
mongo.connect('mongodb://localhost:27017/lwtm2m', function(err, db) {
mongo.connect('mongodb://localhost:27017/lwtm2m', { useNewUrlParser: true }, function(err, db) {
iotAgentDb = db;
done();
});
Expand All @@ -73,7 +73,7 @@ describe('MongoDB Device registry', function() {
delete config.server.deviceRegistry;
delete config.server.mongodb;

iotAgentDb.db().collection('devices').remove(function(error) {
iotAgentDb.db().collection('devices').deleteOne(function(error) {
iotAgentDb.close(function(error) {
libLwm2m2.stop(testInfo.serverInfo, done);
});
Expand Down

0 comments on commit eca9474

Please sign in to comment.