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

Model#destroy & Model#update #2

Open
7imon7ays opened this issue Dec 14, 2014 · 0 comments
Open

Model#destroy & Model#update #2

7imon7ays opened this issue Dec 14, 2014 · 0 comments

Comments

@7imon7ays
Copy link
Owner

Should be able to call model.update({ foo: "bar", baz: null }) and model.destroy(). Both require models to track what row they're in.

To reproduce the behavior of a regular spreadsheet, Model#destroy should remove the entire row. This has the side-effect of changing the row number of every record with a greater row number.

Possible solutions:

  1. Mark deleted record's row as "archived" instead of removing it. Bad: Sheet eventually becomes filled with junk**. Poor usability and performance.
  2. Require a separate, unique, non-null column in every sheet to identify records after rows have been deleted. Bad: Too big a requirement from the user.
  3. Keep every instantiated record in an array, sorted by row number. When a record is deleted, update the row number of all instantiated records that had a greater row number. Bad: Deletion becomes Log(n) + n / 2 operation. Log(n) at worst to find the first instance with a greater row number in the sorted array + n/2 on average to update those rows. Race condition if the user manually changes the sheet while Goodel is running.

Option 3 looks best.

** Not a bad idea to have an "archive" instance method. Opened #8.

@7imon7ays 7imon7ays changed the title Model#remove Model#remove & Model#update Dec 16, 2014
@7imon7ays 7imon7ays changed the title Model#remove & Model#update Model#destroy & Model#update Dec 16, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant