Skip to content

Instantly share code, notes, and snippets.

@rjcorwin
Last active December 14, 2015 11:39
Show Gist options
  • Save rjcorwin/5080816 to your computer and use it in GitHub Desktop.
Save rjcorwin/5080816 to your computer and use it in GitHub Desktop.
Idea for a JSON object that lives on the file system. It's like a key value store where your keys forge a trail so clients can find just the data they are looking for without having to use SQL or map reduce. TrailDB?

This JSON object... Check it out.

{
  "slogan": "Simplicity is the key to our values",
  "theAnswer": 42,
  "isAwake": true,
  "shoppingList: [
    "water", 
    "lightbulbs", 
    "milk"
  ],
  "favoriteThings" {
    "number": 72, 
    "color": "blue",
  }
}

Converts to HSON (Hammock Structured Object Notation)...

./_map -> {"slogan": "String", "theAnswer": "Integer", "isAwake": "Boolean", "shoppingList": "Array", "favoriteThings": "Object" } ./slogan -> "Simplicity is the key to our values" ./theAnswer -> 42 ./isAwake -> true ./shoppingList/0 -> "water" ./shoppingList/1 -> "lightbulbs" ./shoppingList/2 -> "milk" ./favoriteThings/_map -> {"number": "Integer", "color": "String"} ./favoriteThings/number -> 72 ./favoriteThings/color -> "blue"

With that structure you can programatically follow, on the file system or mounted on something like Apache Server, the _map files getting only the data you want.

The optional server

  • An HTTP server that mounts any directory with HSON to perform RESTful functions on the database. -- Ability to POST JSON to an area in the tree --- curl -XPUT http://127.0.0.1:0042/favoriteStuff -d "{'color':'blue', 'sport':'pinball', 'cats': ['Reginald', 'Reggy', 'Robert James']}" --- would result in... --- curl -XGET http://127.0.0.1:0042/favoriteStuff/sport --- returns: "pinball" --- also... curl -XGET http://127.0.0.1:0042/favoriteStuff/_id --- returns a UUID added automatically. This is useful for keeping track of data. The folder directories is just the trail to the data. -- Ability to return all or some of the JSON --- curl -XGET http://127.0.0.1:0042/favoriteStuff?depth=1 --- returns: {'color':'blue', 'sport':'pinball', 'names': []} --- curl -XGET http://127.0.0.1:0042/favoriteStuff?depth=2 --- returns: {'color':'blue', 'sport':'pinball' 'names': ['Reginald', 'Reggy', 'Robert James']} -- Ability to to do range queries --- For example, http:/127.0.0.1:0042/favoriteStuff?startkey="a"&endkey="c" --- returns: {'color':'blue', 'cats': ['Reginald', 'Reggy', 'Robert James']}
@bcipolli
Copy link

I don't quite get this. Could you talk about how you'd like this to work for the KA topic tree? Thanks...!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment