Closed marcello3d closed 13 years ago
Could make gridfs.create
something along the lines of
gridfs.create = function(descriptor, callback){
if(callback) { /* do it async /}
else { / stick with non-async */}
and then do the same with save()
. Seems that way you get the best of both worlds
I've decided to keep the API the same. gridfs.create returns immediately and doesn't actually save anything until you start writing to its write stream. file.save() now has an asynchronous callback to make this happen correctly.
Either make gridfs.create() asynchronous, or make gridfile.save() asynchronous and have it search for an existing file if it has no _id.
The former would make the programmer more aware of what's going on, while the latter can cleanly use the existing api.