Git Product home page Git Product logo

Comments (4)

gruns avatar gruns commented on May 21, 2024 1

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.

gruns avatar gruns commented on May 21, 2024

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.

martindrapeau avatar martindrapeau commented on May 21, 2024

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.

gruns avatar gruns commented on May 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.