Issues (82)

app/experiments/mongo-delete.js (7 issues)

1
const {MongoClient} = require('mongodb');
2
3
MongoClient.connect('mongodb://localhost:27017/JokesApp', (err, db) => {
4
    if (err){
5
        return console.log('failed to connect to mongodb server. ', err);
0 ignored issues
show
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
6
    }
7
8
    console.log('Connected to MongoDB Server');
9
10
    //deleteMany - delete all the occcurences
11
    db.collection('Jokes').deleteMany({joke : 'Sample joke 2'}).then((result) => {
12
        console.log(result.result);
0 ignored issues
show
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
13
    }, (err) => {
14
        cosole.log('Error deleting many. E : ', err)
0 ignored issues
show
The variable cosole seems to be never declared. If this is a global, consider adding a /** global: cosole */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
15
    });
16
17
    //deleteOne - deletes only first occurence of all the occurences
18
    db.collection('Jokes').deleteOne({joke : 'Test 1'}).then((result) => {
19
        console.log(result.result);
0 ignored issues
show
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
20
    });
21
22
    db.collection('Jokes').findOneAndDelete({joke : 'Test 2'}).then((doc) => {
23
        console.log(doc);
0 ignored issues
show
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
24
    }, (err) => {
25
        console.log('Error find one and delete. E: ', err);
0 ignored issues
show
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
26
    });
0 ignored issues
show
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
27
28
    //close the DB
29
    // db.close();
30
});