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

Uses dictionary structure to store records in the database #21

Merged
merged 1 commit into from Dec 22, 2020

Conversation

kettanaito
Copy link
Member

@kettanaito
Copy link
Member Author

kettanaito commented Dec 22, 2020

Hey, @marcosvega91. I've used your pull request (#13) to migrate to the dictionary. Sorry, I didn't want to bother you with a bunch of comments on the holiday's eve, I hope you don't mind that I rewrote this.

It's mostly the same with a few exceptions:

  • Primary key is determined in parseModelDeclaration, so we don't have to do that twice.
  • Primary key is required and we don't use a fallback to id. I find it a too presumptuous decision and would prefer the end developer to explicitly specify primary keys for their models.
  • Primary key is stored in the internal entity properties, alongside __type and __nodeId.
  • Model methods now use other model methods (i.e. delete uses findFirst and then deletes that found record).
  • Querying by the primary key is done by applying the query on the temporary { [primaryKey]: keyValue } object, so we don't have to re-implement how compileQuery works for this use case.

If you have a minute I'd appreciate it if you gave these changes a review, as I'm not sure I've covered all the cases we've talked about. Thank you.

@kettanaito
Copy link
Member Author

kettanaito commented Dec 22, 2020

I have one question: with the introduction of the primary key it effectively becomes the __nodeId, doesn't it?

Should we still use an internal __nodeId, or should we now rely on __primaryKey? I wouldn't rework this now, but a thing to consider.

Copy link
Member

@marcosvega91 marcosvega91 left a comment

Choose a reason for hiding this comment

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

it looks that all cases are covered here. About your question on node_id, I think that it can be removed. Good work 😄

@kettanaito kettanaito merged commit d0f48e6 into master Dec 22, 2020
@kettanaito kettanaito deleted the use-dictionary branch December 22, 2020 12:06
@kettanaito
Copy link
Member Author

Thank you for the work on this, @marcosvega91. This pull request wouldn't have been possible without yours.

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

Successfully merging this pull request may close these issues.

Restructure database to a dictionary
2 participants