Closed aabm00 closed 10 years ago
this seems like reasonable behavior to me.
let's walk through it: I want to make sure something is gone. it is. throw error?
Sorry for the delay, and thanks for your answer
The thing is that I Hoped that when I try to make a remove of a file that doesn't exists in the database (The Id doesn't exits) gfs.remove({ _id : id }, function(err){... fired an error. But it didn't. For your answer I understand that this is a normal behaviour. Isn't it?
The thing Is that the only way I could control if the file existed or not was making a : gfs.files.find(options).toArray(function(err, files){ if( err || files.length === 0 ){...
before call the remove method, in this way as files.length === 0 I can fire the error from here. But I don't understand because gfs.remove({ _id : id }, function(err){... don't fired an error when the id don't exists in the database.
Thanks Toni
Hello.
I'm testing my code, and trying to remove a fake id (it doesn't exists in the Database). The problem is that it doesn't fire an error, but resolves like if it success deleting it
My code is:
var doDeleteById = function(id){ var deferred, error, options = { _id : id }; deferred = Q.defer(); gfs.remove(options, function(err){ if(err){ console.log(" EN ERR doDeleteById ***** " + err); error = "The file with Id " + id + " can't be deleted"; deferred.reject( new Error( error )); } console.log(" EN SUCCESS doDeleteById ***** " + 'true'); deferred.resolve(true); }); return deferred.promise; };
There are something I forget?
Thanks Toni.