-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
db.create UnhandledPromiseRejectionWarning: MongoError: a collection 'mytest.test' already exists even when it's new #310
Comments
Actually, even simpler test case: const monk = require('monk');
const db = monk('mongodb://localhost/test');
const test = async () => {
var collection = db.create('test');
await collection.insert({name: 'a'});
db.close();
};
test(); It looks like the implicit collection creation is getting muddled up with the earlier explicit one. This time Ubuntu 20.04; monk 7.3.0; mongodb-org 4.2.8 |
And adding debugging adds a bit of info, but not much: const monk = require('monk');
const db = monk('mongodb://localhost/test');
db.addMiddleware(require('monk-middleware-debug'))
const test = async () => {
var collection = db.create('test', {}, {'safe':false});
await collection.insert({name: 'a'});
db.close();
};
test();
|
same issue, have any solutions? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If I try to create a new database and add a few entries to it, I get an
UnhandledPromiseRejectionWarning
.This is the simplest script I can get to see the error (it does need to insert data):
If the collection does not exist before running the script, I get the following error:
The collection is created and the documents are successfully added.
If the collection does already exist, output is silent. The documents are added to the collection.
It's almost like it's operating backwards!
monk 7.3.0; mongodb 1:3.6.3-0ubuntu2.1 (yes, I need to shift to a newer version of Ubuntu to upgrade this)
The text was updated successfully, but these errors were encountered: