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

Undelete API #167

Closed
Juul opened this issue Aug 1, 2017 · 2 comments
Closed

Undelete API #167

Juul opened this issue Aug 1, 2017 · 2 comments
Assignees

Comments

@Juul
Copy link
Member

Juul commented Aug 1, 2017

All deleted materials (physicals or virtuals) should be copied to a sublevel before deletion. This should be done as a batch so it stays atomic. The key in this "list of deleted materials" sublevel should be datetime, sorted by newest first.

New API functions:

  • List deleted materials in newest-first order
  • Restore material
  • Permanently delete (remove from list of deleted materials)

This sublevel should auto-delete anything older than 30 days.

Restore material should copy the material back to the normal sublevel from whence it was deleted and remove the entry from the list of deleted items. Again as an atomic batch operation.

@Juul Juul self-assigned this Aug 1, 2017
@Juul
Copy link
Member Author

Juul commented Aug 10, 2017

Undeletion API is implemented but untested. I'm working on #182 and will then implement tests for this.

How it works

Anything deleted with delPhysical is automatically saved in a separate database before deletion.

There are three new calls: listDeleted, clearDeleted and undelete.

listDeleted(); // returns a stream of all deleted (keys and values)

listDeleted streams items like this:

{
  key: myKey // key used to undelete
  value: {
    db: dbName, // name of database from which the item was deleted, e.g. "physical"
    key: someKey, // full key, should not be used by client
    deletedAt: someTime, // deletion time in microseconds since unix epoch
    deletedBy: email, // email address of user that deleted this
    data: { ... } // the actual deleted object
  }
}
clearDeleted(callback); // permanently delete the deleted items (empty recycle bin)
undelete(key, callback); // undelete the item and remove it from the list of deleted items

@Juul
Copy link
Member Author

Juul commented Aug 10, 2017

Tested and working as of 3fed7df

@Juul Juul closed this as completed Aug 10, 2017
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