@clickup/ent-framework
Version:
A PostgreSQL graph-database-alike library with microsharding and row-level security
33 lines • 1.17 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.CanUpdateOutgoingEdge = void 0;
const Predicate_1 = require("./Predicate");
/**
* Checks that an Ent available via a field is updatable. See
* CanReadOutgoingEdge comments for more details.
*/
class CanUpdateOutgoingEdge {
constructor(field, toEntClass) {
this.field = field;
this.toEntClass = toEntClass;
this.name = this.constructor.name + "(" + this.field + ")";
}
async check(vc, row) {
const toID = row[this.field];
if (!toID) {
return false;
}
const cache = vc.cache(Predicate_1.IDsCacheUpdatable);
if (cache.has(toID)) {
return true;
}
// load the target Ent and check that it's updatable
const toEnt = await this.toEntClass.loadX(vc, toID);
await this.toEntClass.VALIDATION.validateUpdate(vc, toEnt, {}, true /* privacyOnly */);
// sill here and not thrown? save to the cache
cache.add(toID);
return true;
}
}
exports.CanUpdateOutgoingEdge = CanUpdateOutgoingEdge;
//# sourceMappingURL=CanUpdateOutgoingEdge.js.map
;