Commit fc2fddf9 authored by nanahira's avatar nanahira

allow partial entity in create

parent 705acc1f
...@@ -140,10 +140,12 @@ export class CrudBase<T extends ValidCrudEntity<T>> { ...@@ -140,10 +140,12 @@ export class CrudBase<T extends ValidCrudEntity<T>> {
return result; return result;
} }
async create(ent: T, beforeCreate?: (repo: Repository<T>) => Promise<void>) { async create(_ent: T, beforeCreate?: (repo: Repository<T>) => Promise<void>) {
if (!ent) { if (!_ent) {
throw new BlankReturnMessageDto(400, 'Invalid entity').toException(); throw new BlankReturnMessageDto(400, 'Invalid entity').toException();
} }
const ent = new this.entityClass();
Object.assign(ent, _ent);
const invalidReason = ent.isValidInCreate(); const invalidReason = ent.isValidInCreate();
if (invalidReason) { if (invalidReason) {
throw new BlankReturnMessageDto(400, invalidReason).toException(); throw new BlankReturnMessageDto(400, invalidReason).toException();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment