Skip to content
This repository was archived by the owner on Jan 21, 2026. It is now read-only.

feat: IndexedDB prototype#18

Merged
brodrigu merged 5 commits into
prototypesfrom
indexeddb
Apr 7, 2021
Merged

feat: IndexedDB prototype#18
brodrigu merged 5 commits into
prototypesfrom
indexeddb

Conversation

@iamnewton

@iamnewton iamnewton commented Apr 2, 2021

Copy link
Copy Markdown
Contributor

The concept here is to showcase that browser support for IndexedDB is widespread and will work as a mechanism for storing Interest Groups and other auction data.

This shows IndexedDB working locally and presumably in production, but from the same domain. It's currently using a wrapper library from Jake Archibald called idb.

Resources


To Do

Fixes: #16

@iamnewton iamnewton changed the title chore: IndexedDB chore: IndexedDB prototype Apr 2, 2021
@iamnewton iamnewton requested a review from brodrigu April 2, 2021 21:23
@iamnewton iamnewton self-assigned this Apr 2, 2021
@iamnewton iamnewton added the prototype A working model to test out theories label Apr 2, 2021
@iamnewton iamnewton added this to the Prototypes milestone Apr 2, 2021
@iamnewton iamnewton linked an issue Apr 2, 2021 that may be closed by this pull request
@iamnewton iamnewton added the draft label Apr 2, 2021
@iamnewton iamnewton changed the title chore: IndexedDB prototype feat: IndexedDB prototype Apr 2, 2021
Comment thread prototypes/indexed-db/basic/scripts/db.js
name: "womens-running-shoes",
date: Date.now(),
expire: Date.now() + (30 * 86400000),
});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

when we use this for real we should generate our own id, probably something like ${owner}-${name} for quick lookup and to enforce the requirements.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I agree we should sit down and figure out a new schema for this now that we have a dB.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

my suggestion is for the primary key to be named key if possible and for it to be ${owner}-${name}.

In addition, we should have an index on the _expires key so we can easily find articles that have expired:

store.createIndex('_expires', '_expires');

Basically we use what is described here: https://github.com/MagniteEngineering/fledge.polyfill/blob/main/specifications/interest-groups.md but make it a flat structure instead of the owner -> group hierarchy.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Commit: 6afbd46

Comment thread prototypes/indexed-db/basic/scripts/db.js
Comment thread prototypes/indexed-db/basic/scripts/db.js
Newton Koumantzelis added 4 commits April 5, 2021 17:19
- Update `id` field as key to `_key`
- Create an index on `_expires`

#18 (comment)
This is required because IndexedDB will error if you try to write over
the key with the same key that already exists in the dB, thus since
we're using the `owner-name` as the key, we need to stop trying to
overwrite the dB entry each time the page is refreshed.
@brodrigu brodrigu merged commit efe1d98 into prototypes Apr 7, 2021
@brodrigu brodrigu deleted the indexeddb branch April 7, 2021 17:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

draft prototype A working model to test out theories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create prototype for IndexedDB

2 participants