Giter Site home page Giter Site logo

Comments (8)

mafintosh avatar mafintosh commented on May 27, 2024

I use this to do it, https://github.com/mafintosh/sublevel-prefixer and then i just use the toplevel db.

from subleveldown.

tgohn avatar tgohn commented on May 27, 2024

Thanks for the reply.

From the code, it looks like sublevel-prefixer is not meant to use with nested sublevels.
Because a subleveldown prefix would be in this format sub2.db.prefix === "!sub1!!sub2!"

Just curious, is nested sublevels not a favorable choice?

from subleveldown.

mafintosh avatar mafintosh commented on May 27, 2024

You can calls to sublevel-prefixer
On Tue 4 Aug 2015 at 19:16 John Nguyen [email protected] wrote:

Thanks for the reply.

From the code, it looks like sublevel-prefixer is not meant to use with
nested sublevels.
Because a subleveldown prefix would be in this format sub2.db.prefix ===
"!sub1!!sub2!"

Just curious, is nested sublevels not a favorable choice?


Reply to this email directly or view it on GitHub
#4 (comment)
.

from subleveldown.

mafintosh avatar mafintosh commented on May 27, 2024
  • You can do subsequent calls to sublevel-prefixer
var prefix = prefixer()
prefix('hello', prefix('world', 'stuff')) // !hello!!world!stuff

from subleveldown.

tgohn avatar tgohn commented on May 27, 2024

ah, I see, didnt think of using the prefixer like that.
Thanks a lot @mafintosh 😄

from subleveldown.

mvayngrib avatar mvayngrib commented on May 27, 2024

@mafintosh how would you preserve the correct encodings on members of the batch (assuming they're different from each other or from the top level)?

from subleveldown.

tounano avatar tounano commented on May 27, 2024

@mvayngrib here is what I do.

I always use binary encoding. So whatever I save, I save in binary. For the first week I started doing that it was a headache, but it was bigger headache to work the other way :)

from subleveldown.

CMCDragonkai avatar CMCDragonkai commented on May 27, 2024

So the default separator used in subleveldown is !.

Therefore to acquire the prefix:

var prefix = prefixer('!')

const k = prefix('permissions', 'my-key'); // !my-prefix!my-key

const db = await level();

const permDb = sub(
  db,
  'permissions',
);

db.get(k);

Does that mean k will access the the my-key from permDb?

from subleveldown.

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.