node_acl icon indicating copy to clipboard operation
node_acl copied to clipboard

removeResource leaves empty 'allows' collection

Open caasjj opened this issue 10 years ago • 2 comments

As I understand it, with mongodB backend, acl_allows.... collections store permissions under role keys. To remove a resource from the system, .removeResource deletes all the roles keys from the resource's acl_allows collection using collection.remove, leaving an empty collection there. Why do this instead of dropping the whole collection with collection.drop?

i.e. define an additional drop method on the backend interface as follows

drop : function(transaction, bucket){
        contract(arguments).params('array', 'string').end();
        var _this = this;
        var collName = (_this.useSingle? aclCollectionName : bucket);
        transaction.push( function(cb){
            _this.db.collection(_this.prefix + collName, function(err, collection) {
                if (err instanceof Error) return cb(err);
                collection.drop( cb );
            });
        });
    },

and then call backend.drop instead of backend.del in .removeResource - or if the present behavior is still desired, define an additional method, e.g. .deleteResource.

caasjj avatar Jan 02 '15 10:01 caasjj

+1

jerry8050 avatar Sep 16 '16 03:09 jerry8050

Same problem, this leaves the database polluted with many empty collections!

nicky-lenaers avatar Nov 27 '16 20:11 nicky-lenaers