giorgio-zamparelli / mongo-in-memory

in memory mocking engine for mongo db
25 stars 4 forks source link

Issue with UnhandledPromiseRejectionWarning: Unhandled promise rejection #5

Open AlirezaAtGeeks opened 7 years ago

AlirezaAtGeeks commented 7 years ago

Could you please update line 160 with

collection.insertOne(document, function (error, result) { if (error) { reject(error); } else if (result.n === 0) { reject(new Error("no document was actually saved in the database")); } else { resolve(result.ops[0]); } });

Also when I run mocha in recursive mode, it's complaining about UnhandledPromiseRejectionWarning: Unhandled promise rejection. What do you suggest?

giorgio-zamparelli commented 7 years ago

@AlirezaAtGeeks could you create a Pull Request for me to approve? How to create a Pull Request tutorial

The unhandled promise rejection I think is something you have to manage in your code either by adding a .catch or with process.on('unhandledRejection', error => { console.log('unhandledRejection', error.message); }); Unhandled Promise Rejections in Node.js

AlirezaAtGeeks commented 7 years ago

It seems I don't have permission to push my changes If you think that is not necessary, I can ignore it. However, I wanted to follow the addDocument procedure for handling it.

giorgio-zamparelli commented 7 years ago

Yes it's supposed to be that way. Its a Pull Request not a Push changes! :) Read the tutorial and/or Google it!