Comments (4)
The docs aren't clear on how I can instantiate a DB omitting cookies.
I don't transpile my code. I want to use the .min.js file directly. Can I do
something similar?
Absolutely. Here's how you can accomplish exactly that:
<html>
<head>
<script src="immortal-db.min.js"></script>
<script>
;(async () => {
const stores = [ImmortalDB.LocalStorageStore, ImmortalDB.IndexedDbStore]
const db = ImmortalDB.ImmortalStorage(stores)
await db.set('hi', 'lolsup')
})()
</script>
</head>
...
</html>
Live example: https://codepen.io/anon/pen/LqZvgy?editors=1001#0.
Does that answer your question, @martindrapeau?
from immortaldb.
All sensible suggestions.
I tried to find a workaround for this particular aspect
every cookie set is sent to the server on every request
without success. When a cookie's path
parameter is set to an esoteric path to
obviate transmission to the server, like /c2eb2183ba25438d99e309dddcd8f3c6
,
that cookie also becomes unreadable on all other paths, too. In short, I
couldn't figure out a way to both set, and read, a cookie and simulateously
avoid transmission of that cookie.
Are you aware of any clever techniques that forfend transmission to the server?
Now, if you'll indulge my curiosity, what kind(s) of data do you wish to store
in ImmortalDB? In turn, the kind of data stored connotes the storage
requirements. E.g. bytes vs kilobytes vs megabytes, etc.
If the majority of ImmortalDB users want to store order of magnitude megabytes+
therein, it indeed makes sense to consider the removal of CookieStore
from
ImmortalDB's default data stores.
from immortaldb.
My use case is to store base64 images locally. I never want to send that to the server.
Another reason is for security. I want to build a local-only app. Nothing on the server.
The docs aren't clear on how I can instantiate a DB omitting cookies. I would expect something like this:
var db = new ImmortalDB({
storage: ['IndexedDB', 'LocalStorage', 'SessionStorage']
});
I don't transpile my code. I want to use the .min.js
file directly. Can I do something similar?
from immortaldb.
I'd suggest disabling the cookie storage option by default, making it opt-in.
A fair compromise could be: by default, ImmortalDB
's data stores don't include
CookieStore
; instead just IndexedDbStore
, LocalStorageStore
, and
SessionStorageStore
.
Then, a new, brother instance of ImmortalStorage
-- what ImmortalDB
is an
instance of -- would be exposed globally that does include CookieStore
. This
instance could be called ImmortalCookieDB
, or similar.
Users would then have a choice:
-
ImmortalDB
: More storage, less redundancy, and free from the caveats of
cookies (network transmission, max 4096 bytes per value, etc). -
ImmortalCookieDB
: Less storage, more redundancy, but subject to the
caveats of cookies.
Users would, of course, remain free to instantiate new ImmortalStorage
objects
with whichever permutation of data stores they so desire, a la
import { ImmortalStorage, CookieStore, LocalStorageStore } from 'immortal-db'
const stores = [CookieStore, LocalStorageStore]
const db = ImmortalStorage(stores)
What do you guys think?
from immortaldb.
Related Issues (20)
- how to handle expired mechanism HOT 7
- SSR compatible HOT 6
- Option to remove all cookies set with ImmortalDB HOT 5
- I wouldn't recommend using SessionStorage HOT 3
- Ideas for additional persistent storage HOT 3
- Support for KV Storage HOT 2
- Reset database HOT 4
- Undefined should not be counted as value? HOT 2
- We don't use NPM or any module manager, so am getting "Cannot use import statement outside a module".... HOT 3
- Events HOT 6
- Add testing how-to snippet to the readme
- Set the SameSite attribute of saved cookies HOT 1
- Indexed DB HOT 1
- Differentiate a user-stored `'undefined'` from a deleted key with a sentinel value
- Use JSDoc HOT 3
- Synchronous get / set? HOT 1
- Size limit HOT 1
- Nextjs window is not defined error HOT 7
- You are only allowing strings and return undefined for JSON
- Implement a way to iterate the store keys
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from immortaldb.