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

TypeScript: special case for auto-incrementing primary keys, v2 #252

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

dumbmatter
Copy link

This is an improved version of #151, aimed at solving #150.

The general idea is that you specify the auto-incrementing key's name in DBSchemaValue["autoIncrementKeyPath"], and then internally it labels that property as optional when accepting new records in add and put. It even works with nested keys like "my.nested.id".

As a bonus, when autoIncrementKeyPath is set, createObjectStore now knows what to expect in its 2nd parameter - that it must have an auto incrementing key of the same name. This will help catch some typos.

The only caveat is I'm not sure how to make the 2nd parameter of createObjectStore optional if and only if autoIncrementKeyPath is undefined. See the comment I left in there.

@megagames-me
Copy link

Hi @jakearchibald, any updates on this getting merged or resolving #150? Thanks

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.

None yet

2 participants