Closed AnanthGopal closed 5 years ago
You can customise the controller to deliver that behaviour, if you mean the api response?
@dougal83 just I asked to implement that feature, because that is basic feature so only i am asking. Its okay fine.
@AnanthGopal The loopback 4 framework delivers a CRUD implementation via the CLI. You can alter the controller produced or write your own entirely.
You are free to alter the controller like so for the delete function to give the basic customisation that I think you are after:
@del('/todos/{id}', {
responses: {
'200': {
description: 'Todo DELETE custom boolean response',
content: {
'application/json': {
schema: {
type: 'boolean',
},
},
},
},
},
})
async deleteById(@param.path.number('id') id: number): Promise<boolean> {
return await this.todoRepository
.deleteById(id)
.then(() => {
// promise fullfilled ergo successful deletion
return true;
})
.catch(() => {
// promise rejected ergo failure to delete
return false;
});
}
Is this more or less the functionality you are looking for?
Thank you
When we delete the record, we need to return true(Deleted) or false(Not Deleted or error occured)