This is the schema of my database table 'users'
{
"_id": {
"$oid": "572255b0dad7d9781f92d6bd"
},
"local": {
"password": "$2a$08$JMHr7CMBNkFqi1xxFvO9je1w9qi2BP4tR9Z81FsA2N267PNIBD3ma",
"email": "[email protected]"
},
"__v": 0
}
I am trying to remove this from my database using the following code: functions.js:
function deleteUser(finishedEmail){
try{
var socket = io.connect('http://127.0.0.1:8080');
console.log("success");
} catch(e){
console.log("fail");
}
if(socket !== undefined){
var email = finishedEmail;
socket.emit('userDelete',{
email:email
})
}
}
server.js:
var col2 = db.collection('users');
socket.on('userDelete',function(data){
var email = data.email;
console.log(data.email);
col2.deleteOne({email: email}, function(){
console.log("successful deletion");
});
});
In my console I receive the logs: "[email protected]" and "successful deletion". But the email is not deleted. What am I doing wrong?
I've tried the following:
col2.deleteOne({local:{email: email}}, function(){
console.log("successful deletion");
});
col2.deleteOne({email: email}, function(){
console.log("successful deletion");
});
col2.deleteOne({local.email: email}, function(){
console.log("successful deletion");
});