I am trying to setup my mongoDB database using mongoose, but i getting an error “mongoose default promise...












0















I am trying to set up my MongoDB database using mongoose but getting a deprecated warning "Mongoose: mpromise (mongoose's default promise library) is deprecated, plug in your own promise library instead: http://mongoosejs.com/docs/promises.html"



Here is my code for server.js file below:



var mongoose = require('mongoose');
mongoose.promise = require('bluebird');


// mongoose.promise = global.promise;
mongoose.connect('mongodb://localhost:27017/TodoApp');

var Todo = mongoose.model('Todo', {
text: {
type: String
},
completed: {
type: Boolean
},
completedAt: {
type: Number
}
});

var newTodo = new Todo({
text: 'Cook dinner'
});

newTodo.save().then((doc) => {
console.log('Saved todo', doc);
}, (e) => {
console.log('Unable to save todo')
});


I already tried to install bluebird and to use it as my third party promise but still getting the same error message.










share|improve this question


















  • 1





    you could look at this, its kinda duplicate: stackoverflow.com/questions/38138445/…

    – saikat chakrabortty
    Jan 19 at 9:28











  • Possible duplicate of (node:3341) DeprecationWarning: Mongoose: mpromise

    – NoobieSatan
    Jan 19 at 9:30











  • Which version of nodejs you are using? I use node 8. And I dont need to specify promise library, it takes the global one by default.

    – Jayadratha Mondal
    Jan 20 at 3:03
















0















I am trying to set up my MongoDB database using mongoose but getting a deprecated warning "Mongoose: mpromise (mongoose's default promise library) is deprecated, plug in your own promise library instead: http://mongoosejs.com/docs/promises.html"



Here is my code for server.js file below:



var mongoose = require('mongoose');
mongoose.promise = require('bluebird');


// mongoose.promise = global.promise;
mongoose.connect('mongodb://localhost:27017/TodoApp');

var Todo = mongoose.model('Todo', {
text: {
type: String
},
completed: {
type: Boolean
},
completedAt: {
type: Number
}
});

var newTodo = new Todo({
text: 'Cook dinner'
});

newTodo.save().then((doc) => {
console.log('Saved todo', doc);
}, (e) => {
console.log('Unable to save todo')
});


I already tried to install bluebird and to use it as my third party promise but still getting the same error message.










share|improve this question


















  • 1





    you could look at this, its kinda duplicate: stackoverflow.com/questions/38138445/…

    – saikat chakrabortty
    Jan 19 at 9:28











  • Possible duplicate of (node:3341) DeprecationWarning: Mongoose: mpromise

    – NoobieSatan
    Jan 19 at 9:30











  • Which version of nodejs you are using? I use node 8. And I dont need to specify promise library, it takes the global one by default.

    – Jayadratha Mondal
    Jan 20 at 3:03














0












0








0








I am trying to set up my MongoDB database using mongoose but getting a deprecated warning "Mongoose: mpromise (mongoose's default promise library) is deprecated, plug in your own promise library instead: http://mongoosejs.com/docs/promises.html"



Here is my code for server.js file below:



var mongoose = require('mongoose');
mongoose.promise = require('bluebird');


// mongoose.promise = global.promise;
mongoose.connect('mongodb://localhost:27017/TodoApp');

var Todo = mongoose.model('Todo', {
text: {
type: String
},
completed: {
type: Boolean
},
completedAt: {
type: Number
}
});

var newTodo = new Todo({
text: 'Cook dinner'
});

newTodo.save().then((doc) => {
console.log('Saved todo', doc);
}, (e) => {
console.log('Unable to save todo')
});


I already tried to install bluebird and to use it as my third party promise but still getting the same error message.










share|improve this question














I am trying to set up my MongoDB database using mongoose but getting a deprecated warning "Mongoose: mpromise (mongoose's default promise library) is deprecated, plug in your own promise library instead: http://mongoosejs.com/docs/promises.html"



Here is my code for server.js file below:



var mongoose = require('mongoose');
mongoose.promise = require('bluebird');


// mongoose.promise = global.promise;
mongoose.connect('mongodb://localhost:27017/TodoApp');

var Todo = mongoose.model('Todo', {
text: {
type: String
},
completed: {
type: Boolean
},
completedAt: {
type: Number
}
});

var newTodo = new Todo({
text: 'Cook dinner'
});

newTodo.save().then((doc) => {
console.log('Saved todo', doc);
}, (e) => {
console.log('Unable to save todo')
});


I already tried to install bluebird and to use it as my third party promise but still getting the same error message.







javascript node.js mongodb mongoose es6-promise






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 19 at 9:23









Abhinav AnshulAbhinav Anshul

315




315








  • 1





    you could look at this, its kinda duplicate: stackoverflow.com/questions/38138445/…

    – saikat chakrabortty
    Jan 19 at 9:28











  • Possible duplicate of (node:3341) DeprecationWarning: Mongoose: mpromise

    – NoobieSatan
    Jan 19 at 9:30











  • Which version of nodejs you are using? I use node 8. And I dont need to specify promise library, it takes the global one by default.

    – Jayadratha Mondal
    Jan 20 at 3:03














  • 1





    you could look at this, its kinda duplicate: stackoverflow.com/questions/38138445/…

    – saikat chakrabortty
    Jan 19 at 9:28











  • Possible duplicate of (node:3341) DeprecationWarning: Mongoose: mpromise

    – NoobieSatan
    Jan 19 at 9:30











  • Which version of nodejs you are using? I use node 8. And I dont need to specify promise library, it takes the global one by default.

    – Jayadratha Mondal
    Jan 20 at 3:03








1




1





you could look at this, its kinda duplicate: stackoverflow.com/questions/38138445/…

– saikat chakrabortty
Jan 19 at 9:28





you could look at this, its kinda duplicate: stackoverflow.com/questions/38138445/…

– saikat chakrabortty
Jan 19 at 9:28













Possible duplicate of (node:3341) DeprecationWarning: Mongoose: mpromise

– NoobieSatan
Jan 19 at 9:30





Possible duplicate of (node:3341) DeprecationWarning: Mongoose: mpromise

– NoobieSatan
Jan 19 at 9:30













Which version of nodejs you are using? I use node 8. And I dont need to specify promise library, it takes the global one by default.

– Jayadratha Mondal
Jan 20 at 3:03





Which version of nodejs you are using? I use node 8. And I dont need to specify promise library, it takes the global one by default.

– Jayadratha Mondal
Jan 20 at 3:03












2 Answers
2






active

oldest

votes


















-1














You should use



mongoose.Promise = require('bluebird');


You are using



mongoose.promise = require('bluebird');


Also I think you are using older version of nodejs. I use node js 8 & mongoose takes global.Promise by default as nodejs 8 comes with native Promise.






share|improve this answer
























  • I am able to use ES-6 version of promise instead of bluebird, but unable to save it to my MongoDB database.i'm getting my second console.log message printing.

    – Abhinav Anshul
    Jan 20 at 5:51











  • @AbhinavAnshul what is the error message. Print the error message & paste here.

    – Jayadratha Mondal
    Jan 20 at 6:12











  • It worked, I had few files corrupted in MongoDB application as well as I use outdated Nodejs. Thank you so much for helping.

    – Abhinav Anshul
    Jan 20 at 7:10



















1














try using this code mate



var mongoose = require('mongoose');

mongoose.Promise = global.Promise;
mongoose.connect('mongodb://10.7.0.3:27107/data/TodoApp');





share|improve this answer

























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54265674%2fi-am-trying-to-setup-my-mongodb-database-using-mongoose-but-i-getting-an-error%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    -1














    You should use



    mongoose.Promise = require('bluebird');


    You are using



    mongoose.promise = require('bluebird');


    Also I think you are using older version of nodejs. I use node js 8 & mongoose takes global.Promise by default as nodejs 8 comes with native Promise.






    share|improve this answer
























    • I am able to use ES-6 version of promise instead of bluebird, but unable to save it to my MongoDB database.i'm getting my second console.log message printing.

      – Abhinav Anshul
      Jan 20 at 5:51











    • @AbhinavAnshul what is the error message. Print the error message & paste here.

      – Jayadratha Mondal
      Jan 20 at 6:12











    • It worked, I had few files corrupted in MongoDB application as well as I use outdated Nodejs. Thank you so much for helping.

      – Abhinav Anshul
      Jan 20 at 7:10
















    -1














    You should use



    mongoose.Promise = require('bluebird');


    You are using



    mongoose.promise = require('bluebird');


    Also I think you are using older version of nodejs. I use node js 8 & mongoose takes global.Promise by default as nodejs 8 comes with native Promise.






    share|improve this answer
























    • I am able to use ES-6 version of promise instead of bluebird, but unable to save it to my MongoDB database.i'm getting my second console.log message printing.

      – Abhinav Anshul
      Jan 20 at 5:51











    • @AbhinavAnshul what is the error message. Print the error message & paste here.

      – Jayadratha Mondal
      Jan 20 at 6:12











    • It worked, I had few files corrupted in MongoDB application as well as I use outdated Nodejs. Thank you so much for helping.

      – Abhinav Anshul
      Jan 20 at 7:10














    -1












    -1








    -1







    You should use



    mongoose.Promise = require('bluebird');


    You are using



    mongoose.promise = require('bluebird');


    Also I think you are using older version of nodejs. I use node js 8 & mongoose takes global.Promise by default as nodejs 8 comes with native Promise.






    share|improve this answer













    You should use



    mongoose.Promise = require('bluebird');


    You are using



    mongoose.promise = require('bluebird');


    Also I think you are using older version of nodejs. I use node js 8 & mongoose takes global.Promise by default as nodejs 8 comes with native Promise.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jan 20 at 3:09









    Jayadratha MondalJayadratha Mondal

    3391417




    3391417













    • I am able to use ES-6 version of promise instead of bluebird, but unable to save it to my MongoDB database.i'm getting my second console.log message printing.

      – Abhinav Anshul
      Jan 20 at 5:51











    • @AbhinavAnshul what is the error message. Print the error message & paste here.

      – Jayadratha Mondal
      Jan 20 at 6:12











    • It worked, I had few files corrupted in MongoDB application as well as I use outdated Nodejs. Thank you so much for helping.

      – Abhinav Anshul
      Jan 20 at 7:10



















    • I am able to use ES-6 version of promise instead of bluebird, but unable to save it to my MongoDB database.i'm getting my second console.log message printing.

      – Abhinav Anshul
      Jan 20 at 5:51











    • @AbhinavAnshul what is the error message. Print the error message & paste here.

      – Jayadratha Mondal
      Jan 20 at 6:12











    • It worked, I had few files corrupted in MongoDB application as well as I use outdated Nodejs. Thank you so much for helping.

      – Abhinav Anshul
      Jan 20 at 7:10

















    I am able to use ES-6 version of promise instead of bluebird, but unable to save it to my MongoDB database.i'm getting my second console.log message printing.

    – Abhinav Anshul
    Jan 20 at 5:51





    I am able to use ES-6 version of promise instead of bluebird, but unable to save it to my MongoDB database.i'm getting my second console.log message printing.

    – Abhinav Anshul
    Jan 20 at 5:51













    @AbhinavAnshul what is the error message. Print the error message & paste here.

    – Jayadratha Mondal
    Jan 20 at 6:12





    @AbhinavAnshul what is the error message. Print the error message & paste here.

    – Jayadratha Mondal
    Jan 20 at 6:12













    It worked, I had few files corrupted in MongoDB application as well as I use outdated Nodejs. Thank you so much for helping.

    – Abhinav Anshul
    Jan 20 at 7:10





    It worked, I had few files corrupted in MongoDB application as well as I use outdated Nodejs. Thank you so much for helping.

    – Abhinav Anshul
    Jan 20 at 7:10













    1














    try using this code mate



    var mongoose = require('mongoose');

    mongoose.Promise = global.Promise;
    mongoose.connect('mongodb://10.7.0.3:27107/data/TodoApp');





    share|improve this answer






























      1














      try using this code mate



      var mongoose = require('mongoose');

      mongoose.Promise = global.Promise;
      mongoose.connect('mongodb://10.7.0.3:27107/data/TodoApp');





      share|improve this answer




























        1












        1








        1







        try using this code mate



        var mongoose = require('mongoose');

        mongoose.Promise = global.Promise;
        mongoose.connect('mongodb://10.7.0.3:27107/data/TodoApp');





        share|improve this answer















        try using this code mate



        var mongoose = require('mongoose');

        mongoose.Promise = global.Promise;
        mongoose.connect('mongodb://10.7.0.3:27107/data/TodoApp');






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Jan 20 at 2:58

























        answered Jan 19 at 10:30









        THEWOLFTHEWOLF

        6381112




        6381112






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54265674%2fi-am-trying-to-setup-my-mongodb-database-using-mongoose-but-i-getting-an-error%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Homophylophilia

            Updating UILabel text programmatically using a function

            Cloud Functions - OpenCV Videocapture Read method fails for larger files from cloud storage