Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async updateAndGet>(
command: IdUpdateCommand
): Promise {
const { entityName, id, filter } = command;
try {
const entity = PhenylStateFinder.get(this.entityState, {
entityName,
id
});
const matched = filter ? retrieve([entity], filter).length === 1 : true;
if (!matched) {
throw createServerError(
`Entity has been locked. entityName:${entityName}, id: ${id}`
);
}
const operation = PhenylStateUpdater.updateById(
this.entityState,
command
);
// @ts-ignore operation is nonbreaking
this.entityState = update(this.entityState, operation);
return PhenylStateFinder.get(this.entityState, {
entityName,
id
});
static find>(
state: EntityState,
query: WhereQuery
): ResponseEntity[] {
const { entityName, where, sort, skip, limit } = query;
let filtered = retrieve(this.getAll(state, entityName), where);
if (sort != null) {
filtered = sortByNotation(filtered, sort);
}
const skipVal = skip || 0;
const limitVal = limit != null ? limit + skipVal : filtered.length;
return filtered.slice(skipVal, limitVal);
}
/**