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

createdBy and updatedBy fields #83

Open
1 of 2 tasks
gmaclennan opened this issue Jul 28, 2023 · 1 comment
Open
1 of 2 tasks

createdBy and updatedBy fields #83

gmaclennan opened this issue Jul 28, 2023 · 1 comment

Comments

@gmaclennan
Copy link
Member

gmaclennan commented Jul 28, 2023

The UX will eventually need a way to show who created and updated any record in the database. Naming chosen to match the createdAt and updatedAt fields.

Both of these could be derived without being stored in the cores:

  1. To derive updatedBy: get the key of the hypercore where the document is stored. If we want a deviceId, then lookup ownership of that core.
  2. To derive createdBy: follow history of any document until you reach the original (empty links[]), and get the updatedBy for that document.

We could just store these on each document which would simplify the code, but that would mean that this information is untrusted / unverified (someone writing directly to the database could write what they want for these fields).

@mapeo/schema does not feel like the right place to derive this information: it would require information about core ownership. Also, versionId before the @ is already the key of the hypercore where the document is stored.

@mapeo/sqlite-indexer could index the creatorCoreId, by writing it to the sqlite index when it encounters the root document (e.g. the document with no links[] record).

mapeo-core is probably the best place to convert the coreId from versionId to a device ID for updatedBy, and it can also convert the creatorCoreId into a device ID for createdBy.

@achou11
Copy link
Member

achou11 commented Sep 13, 2023

@gmaclennan createdBy is now handled after merging #142. What's the best way to update this issue? (which is maybe little outdated to begin with)

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