Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Draft: TruffleDB LevelDB #4680

Closed
wants to merge 36 commits into from
Closed

Draft: TruffleDB LevelDB #4680

wants to merge 36 commits into from

Conversation

tenthirtyone
Copy link
Contributor

@tenthirtyone tenthirtyone commented Feb 1, 2022

Description

A WIP for all things related to truffledb. This draft provides a look at a leveldb implementation that provides the ability to define flexible classes for each model.

The lines changed is deceptive, in all the work is ~350 lines of code supported by 700 of unit tests, readme and a yarn.lock change for the new packages.

I suggest browsing the README for a look at how models are defined, their API and how to create model instances for db records. Then, check the src/storage/Model.js file for the base class that holds the majority of the logic.

To Test

$ yarn test


#### `keyField` - TODO

Currently set to 'id' for all models. Used to denote a property on the Model that serves as the key used by the database.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎨 Cool to let people change this value. Is there a common reason people do this? Maybe if a key foreign key serves the purpose and you don't need an additional id?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, awesome question.

There was an ask that we support Content Addressable Storage IDs. It makes a lot of sense for anything that is deployed. I wasn't sure if an internal 'id' field used by the db and an additional CAS id for the user would be helpful - or if the CAS id could do both roles.

For anything under active development with changing content I think db id + CAS id will help when cycling historical versions as the CAS id would change based on content (especially when multiple devs work off the same project data). And it would make it easier to identify which historical versions made it on chain.

Your point makes a lot of sense and giving the ability to change the key field may introduce more complexity than is necessary. Really, with the way sublevel namespaces the db it would be possible to use something like ${projectName}-CASID as a sort of composite/foreign key solution. Definitely interesting and worth trying or pursuing.

The shorter answer was I just didn't know the correct solution at the time and sided with flexibility until getting some feedback.

@cds-amal
Copy link
Member

The lines changed is deceptive, in all the work is ~350 lines of code supported by 700 of unit tests ...

<3

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

Successfully merging this pull request may close these issues.

3 participants