-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
custom encoding options on db from client. #63
Comments
The test I used initially is this:
error:
|
ah... I think that multilevel doesn't actually implement this correctly. The quick fix is to encode your own keys using bytewise/hex and then pass that to multilevel as a string. The better fix is to make a pull request to multilevel that does this for all requests... in a way that is consistent with levelup. |
I set a couple breakpoints and:
I'll see if I can figure out what's going on but based on this the Hopefully I can work towards that PR... we'll see. :-) |
Whats happening is the object is encoded with json which removes the function (that would be a massive security hole, like an sql injection) Basically you need to encode the object before you send it, or make it so that multilevel encodes the object for you... hmm, now that I think about it, multilevel does use an encoding that supports buffers, so if you set |
that will work but multilevel should still support encodings the same way as levelup, so i'll be working on this now |
i'm working on an implementation that will work, but i'm thinking more and more that multilevel as a leveldown implementation will work better, so we don't need to reinvent levelup logic |
relevant: #64 and Level/levelup#313 |
does this mean i can't do this anymore? db.get('foo', {valueEncoding: myOwnEncoder}, cb) i usually do that when using protocol-buffers, https://github.com/mafintosh/protocol-buffers#leveldb-encoding-compatibility |
currently you can't do that from the client, but i don't remember this ever working with multilevel |
@juliangruber ah whoops. meant to add the comment to Level/levelup#313 (added it there as well now) |
if you pass
require('bytewise/hex')
as thekeyEncoding
in a.batch, .put, .createReadStream...
(as passed in theopts
parameter) on the client it'll just receive an error back saying.encode
is not a method.I'm guessing this isn't something that could be stored in the manifest. So is this something that one would have to tweak/setup server-side? Shim the client's methods to do the key-encoding client side?
The documentation says
binary
encoding is supported, but maybe it would help other's to say custom encodings aren't. Bytewise seems to be a pretty fundamental encoding for level... I almost wish it were native likejson
andbinary
but maybe it's bloat. Thoughts?Probably this is related to #17 and #12 but not certain.
The text was updated successfully, but these errors were encountered: