Skip to content
This repository has been archived by the owner on Nov 7, 2019. It is now read-only.

valid keys #1

Open
whyrusleeping opened this issue Jul 3, 2017 · 1 comment
Open

valid keys #1

whyrusleeping opened this issue Jul 3, 2017 · 1 comment

Comments

@whyrusleeping
Copy link

Does SQL generally have any restrictions on what characters can be used as a 'key' here? IPFS likes to use raw hashes as the keys, i'm not sure how well that would work here. Any ideas @b5 ?

@b5
Copy link
Member

b5 commented Jul 5, 2017

Currently this package is BYO key storage / retrieval, and most (all?) SQL implementations (Postgres, MySQL, Sqlite) will let you store raw byte arrays. Those two things combined should make working with raw hashes no problem.

As an example, we're storing metadata objects by multihash here, with the schema definition for the metadata model here.

You'll notice the schema def uses a text type, that could just as easily be a bytea capped to the exact length of the hash in the db. Translation from bytes into into a go type would happen in the UnmarshalSQL method . I've chosen to store it as a string because datastore.Key.Name() returns a string, and, you know, laziness.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants