@avonjs/avonjs
Version:
A fluent Node.js API generator.
43 lines (42 loc) • 1.29 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = (Parent) => {
class Prunable extends Parent {
attribute;
/**
* Indicates if the underlying field is prunable.
*/
prunable = true;
/**
* The callback used to prunable the field.
*/
pruneUsingCallback = this.pruneCallback;
/**
* Specify the callback that should be used to prunable the field.
*/
pruneUsing(pruneUsingCallback) {
this.pruneUsingCallback = pruneUsingCallback;
return this;
}
/**
* Determine if the underlying file should be pruned when the resource is deleted.
*/
isPrunable() {
return this.prunable;
}
/**
* Specify if the underlying field should be pruned when the resource is deleted.
*/
withPruning(prunable = true) {
this.prunable = prunable;
return this;
}
/**
* Handle pruning for the incoming requests.
*/
async forRequest(request) {
return this.pruneUsingCallback(request, await request.findModelOrFail(), this.attribute);
}
}
return Prunable;
};