A simple node & browser graph database
npm install --save giraffeimport Giraffe from 'giraffe';
const db = new Giraffe();
export default db;- 
new Giraffe(data, callback)data:ObjectOptional- Should be in the shape of 
{ nodes: [], edges: [] } - Labels are created dynamically based on data passed in
 NodesandEdgesare checked for their correct shape.
- Should be in the shape of 
 callback:FunctionOptional- Can be passed first if no data is supplied
 - Callback is called just before returning on each Database Method
 
- Create the DB instance
 
 - 
.create(label, data)label:String||ArrayOptionaldata:Objectlabelis type checked and coerced into a Array within theNodeconstructor
 - 
.remove(nodes)nodes:ArrayArray of Nodes to be removed from graph- this is automatically converted to an Array if a single node is passed in.
 
 - 
.edge([ from ], [ to ], label, properties)fromArrayArray of Nodes where edge originatesto:ArrayArray of Nodes where edge goeslabel:StringOptionalproperties:ObjectOptional
 - 
.query(label, properties)label:StringOptionalproperties:ObjectOptional- you can search for an edge with the property key 
_edges 
- you can search for an edge with the property key 
 - An empty query returns all nodes
 - Queries return only their immediate relationships
 
 - 
.update([ nodes ], [ labels ], data)nodes:Array(or single) node to be updatedlabels:Array(or single) label to be added to Nodes.data:ObjectData set to be merged with previous data, any duplicate keys will be overwritten.- edge labels cannot be updated, an error will be thrown
 
 
{
  /**
   * All relationships with additional properties
   */
  edges: [],
  /**
   * All nodes with properties
   */
  nodes: [],
  /**
   * Dynamic key:value store for tracking known node and edge labels
   */
  labels: {
    nodes: {
      [label]: [/* Array of Node ids */]
    },
    edges: {
      [label]: [/* Array of Edge ids */]
    }
  }
}The callback passed to your DB instance is called before the return statement of every method. That is to say db.create returns the created Node, but just before that return you callback is fired.
The calls are all identical it is called with the Type of request and the modified, added, or removed data.
| method | type | data | 
|---|---|---|
| Create | 'create' | Node | 
| Remove | 'remove' | Array[Node] | 
| Edge | 'edge' | Array[Edge] | 
| Query | 'query' | Array[Query Result] | 
| Update | 'update' | Array[Updated Nodes / Edges] | 
{
  identity: <UUID />,
  properties: Object,
  labels: Array,
  edges: Array,
}propertiesis the object passed into thedb.createmethod.edgesis an array of Edge identity's before a query, after a query it is an array of references to theNode's they represent
{
  identity: <UUID />,
  from: <Node Identity /> || <Node />,
  through: <Node Identity /> || <Node />,
  label: String,
  properties: Object
}propertiesis the object passed into thedb.edgemethod.fromandthroughare stored in the DB asfrom.identityandthrough.identity.- When 
db.queryreturnsfromandthroughare references to theNode's they represent 
Checkout out the TODO Project on Github.
- Complex Queries.
 - Investigate Typescript.