luckyframework / luckyframework/avram
DeleteOperation(T) deletes_dependent feature request
Nobody has claimed this yet.
- Dominant language
- Crystal
- Stars
- 183
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
My recurrent pattern is that my `DeleteOperations` look like this:
```crystal
class DeleteCompany < Avram::DeleteOperation(Company)
before_delete :do_before_delete
def do_before_delete
delete_dependent(record.page!, record.posts!)
end
end
```
...where `page` is a `has_one` relationship and `post` is a `has_many`. `delete_dependent` calls the delete operation on every object passed in its arguments, whether they are singular or arrays. This could be done in a macro, for example:
```crystal
class DeleteCompany < Avram::DeleteOperation(Company)
deletes_dependent :page, :posts
end
```
It's a little easier in my app because my models provide a `#delete_operation(**named_attributes)` instance method that returns a new delete operation for that record. There would have to be a naming convention for the delete operation for this to work.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at DeleteOperation(T) and the existing delete_dependent usage shown in the issue; inspect how dependent records and delete operations are represented. Resolve the naming convention required by a deletes_dependent macro for both has_one and has_many relationships. Done means the macro handles singular and collection dependents, with tests covering each case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- crystal
- Domain
- database
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100