Skip to content

MongoDB Deprecation warning #38

Closed
Closed

Description

@aalfiann

I use mongodb 4.2.0.

here is my connection string

var Agent = require('sqlagent/mongodb').connect('mongodb://127.0.0.1:27017/database');

Then I've got info deprecated.

(node:5317) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
(node:5317) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.

Then I tried to use options like this

var Agent = require('sqlagent/mongodb').connect('mongodb://127.0.0.1:27017/database', { 
    useNewUrlParser: true,
    useUnifiedTopology: true 
});

It's doesn't work because I know in sqlagent/mongodb.js, I can't adding more options.
I've seen that function connect is (conn, callback), no options in there.

So how the solution for this?

Activity

  1. changed the title [-]MongoDB Deprecated[/-] [+]MongoDB Deprecation warning[/+] on Sep 9, 2019
  2. aalfiann commented on Sep 9, 2019

    @aalfiann
    Author

    I've fixed with little modification in mongodb.js.

    with adding this function

    Agent.options = function(obj) {
    	var self = this;
    	Object.keys(obj).forEach(function(key) {
    		OPTIONS[key] = obj[key];
    	});
    	return self;
    }

    So that I'm able to set the options like this

    var Agent = require('sqlagent/mongodb')
        .options({ 
            useNewUrlParser: true, 
            useUnifiedTopology: true 
        })
        .connect('mongodb://127.0.0.1:27017/database');
  3. aalfiann commented on Sep 9, 2019

    @aalfiann
    Author

    Another Deprecation Warning is :

    INSERT

    (node:23048) DeprecationWarning: collection.insert is deprecated. Use insertOne, insertMany or bulkWrite instead.
    

    SAVE

    (node:26992) DeprecationWarning: collection.insert is deprecated. Use insertOne, insertMany or bulkWrite instead.
    

    UPDATE

    (node:23782) DeprecationWarning: collection.update is deprecated. Use updateOne, updateMany, or bulkWrite instead.
    

    DELETE

    (node:21504) DeprecationWarning: collection.remove is deprecated. Use deleteOne, deleteMany, or bulkWrite instead.
    

    For this time I could ignore this warning.

  4. petersirka commented on Sep 9, 2019

    @petersirka
    Collaborator

    Hi @aalfiann, thank you very much (for pull request)... Currently I don't know how to update it. We need to obtain a MongoDB version because of backward compatibility. I'll look into it tomorrow.

  5. aalfiann commented on Sep 10, 2019

    @aalfiann
    Author

    Thank you so much..
    I will waiting for the next update. :D

    Btw, why builder.join and builder.group not support for mongodb? That is very important feature for me.

    I've read in https://docs.totaljs.com/latest/en.html#api~Database

    This sqlagent can be work as nosql embedded. But I don't know how to achieve this. Actually I want to use mongodb but having feature like in databasebuilder.

  6. petersirka commented on Sep 10, 2019

    @petersirka
    Collaborator

    Hi, I have fixed MongoDB. Can you test it? Just download source-code from this repository and copy it to yourproject/node_modules/sqlagent and test your project.

    BTW: joins ... it's a bit complicated and I don't use SQL Agent module because I have written a better + much simpler module called DBMS() and it works only with Total.js framework. But there there isn't updated MongoDB driver yet. https://wiki.totaljs.com/dbms/01-welcome/

  7. aalfiann commented on Sep 11, 2019

    @aalfiann
    Author

    I've already test the update and I can confirm this issue is fixed.

    Thank you very much.

    Btw, I've read all the documentation about DBMS(), It's definitely very powerful because builder.join support multiple of database engine.

    You have to update the MongoDB driver for DBMS(). I'll make some test in my project while waiting for the update. :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions