Created
November 16, 2011 07:56
-
-
Save NuckChorris/1369530 to your computer and use it in GitHub Desktop.
Proposal for Graph API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Noticing that all Graph databases suck massive ass (basically all being in Java | |
| with little or no connection to the outside world except through manual bindings | |
| to whatever environment you want), I decided to imagine up what a good traversal | |
| system would look like to me, using the Redis protocol as my primary inspiration, | |
| with some things (namely the query language) stolen from Mongo (first/most | |
| complete query language for JSON structures I could think of, if you have any | |
| better ideas, please tell me) | |
| Start a transaction set at the root | |
| >> START | |
| << OK | |
| Get our initial starting node with a FIND (applied to the root) | |
| >> FIND {"type":"user","name":"Foo"} | |
| << OK | |
| The relation's key can be any JSON object | |
| >> REL "friends" | |
| << OK | |
| *or* | |
| >> REL {"name":"friends"} | |
| << OK | |
| Find a relationship, using FIND on the current set | |
| Note the use of Mongo's syntax for Greater-than. | |
| >> FIND {"age":{"$gt":18}} | |
| << OK | |
| Now that we've defined the traversal, we tell the server. | |
| This is when the ACTUAL traversal occurs. | |
| >> END | |
| << RETURN {"_id":"__81d2a1482fb3cda6dfd4f354de000c63","name":"Bar","age":10,"friends":["__81d2a1482fb3cda6dfd4f354de000c63"]} | |
| *or* if there was an error: | |
| << ERROR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment