Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chain-ify remove #22

Open
timhuff opened this issue Jan 6, 2014 · 4 comments
Open

Chain-ify remove #22

timhuff opened this issue Jan 6, 2014 · 4 comments

Comments

@timhuff
Copy link
Contributor

timhuff commented Jan 6, 2014

@ApeChimp
I'm going to need Table.remove tomorrow so I'll probably have a go at getting it to resemble Table.find tonight. My thoughts, for your consideration:

I don't want any mishaps with remove. As a result, I thought that all remove calls could take one of the following forms:

Hash Tables
users.remove().one().hash(id)
users.remove().all()

Hash/Range Tables
posts.remove().one().hash(user_id).range(timestamp)
posts.remove().some().hash(user_id)
posts.remove().all()

Any deviation from this (such as providing a range key on a some call) will result in the function throwing an error.

This function is going to be a bit more involved than find because some and all will have to use a query or scan and a batchWrite operation, which can be a bit of a pain. Luckily, I already have these functions in When-DynamoDB, so I should be able to just port them over pretty quickly.

@mike-zorn
Copy link
Collaborator

What's the use case for remove().all() and remove().some()? Normally when I delete a bunch of stuff, I'm doing it as some sort of maintenance thing which isn't a use case I'd like to optimize our api for.

@timhuff
Copy link
Contributor Author

timhuff commented Jan 6, 2014

Yea, my main reason for wanting them would be setting up/tearing down tests. I could also see it coming in handy for a "delete my account" type of functionality.

@mike-zorn
Copy link
Collaborator

I'd just create/destroy the database for setup/teardown (normally a lot less work 😉). I would think delete my account would be able to just use remove().one().hash('foo').

@timhuff
Copy link
Contributor Author

timhuff commented Jan 6, 2014

Creating/destroying the database always seemed a bit extreme but it'd probably be a lot cheaper (depending on the size of the table). But yea, aside from testing, let's say that the user has a collection of posts associated with their account and you want to make it such that deleting the user results in the deletion of all the posts. You would need to use remove().some().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants