{"id":20247320,"url":"https://github.com/tbremer/giraffe","last_synced_at":"2025-04-10T21:32:35.881Z","repository":{"id":57251043,"uuid":"77183594","full_name":"tbremer/Giraffe","owner":"tbremer","description":null,"archived":false,"fork":false,"pushed_at":"2017-03-29T21:47:31.000Z","size":242,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T19:01:40.516Z","etag":null,"topics":["browser","database","databases","graph","graphdb","javascript","node","nodejs"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tbremer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-22T23:48:18.000Z","updated_at":"2022-09-30T19:41:23.000Z","dependencies_parsed_at":"2022-08-24T16:52:12.593Z","dependency_job_id":null,"html_url":"https://github.com/tbremer/Giraffe","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbremer%2FGiraffe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbremer%2FGiraffe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbremer%2FGiraffe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tbremer%2FGiraffe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tbremer","download_url":"https://codeload.github.com/tbremer/Giraffe/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248301824,"owners_count":21080958,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["browser","database","databases","graph","graphdb","javascript","node","nodejs"],"created_at":"2024-11-14T09:36:51.626Z","updated_at":"2025-04-10T21:32:35.853Z","avatar_url":"https://github.com/tbremer.png","language":"JavaScript","readme":"Giraffe\n---\n_A simple node \u0026 browser graph database_\n\n[![Travis CI](https://img.shields.io/travis/tbremer/Giraffe.svg?style=flat-square)](https://travis-ci.org/tbremer/Giraffe)\n[![Version](https://img.shields.io/npm/v/giraffe.svg?style=flat-square)](https://www.npmjs.com/package/giraffe)\n[![NPM Downloads](https://img.shields.io/npm/dm/giraffe.svg?style=flat-square)](https://www.npmjs.com/package/giraffe)\n[![LICENSE](https://img.shields.io/npm/l/giraffe.svg?style=flat-square)](https://github.com/tbremer/Giraffe/blob/master/LICENSE)\n\n## Install\n```shell\nnpm install --save giraffe\n```\n\n## Use\n```javascript\nimport Giraffe from 'giraffe';\n\nconst db = new Giraffe();\n\nexport default db;\n```\n\n## Methods\n- `new Giraffe(data, callback)`\n  - **`data`**: `Object` _Optional_\n    - _Should be in the shape of `{ nodes: [], edges: [] }`_\n    - _Labels are created dynamically based on data passed in_\n    - _`Nodes` and `Edges` are checked for their correct shape._\n  - **`callback`**: `Function` _Optional_\n    - _Can be passed first if no data is supplied_\n    - _Callback is called just before returning on each Database Method_\n  - Create the DB instance\n\n\n- `.create(label, data)`\n  - **`label`**: `String` || `Array` _Optional_\n  - **`data`**: `Object`\n  - _`label` is type checked and coerced into a Array within the `Node` constructor_\n\n\n- `.remove(nodes)`\n  - **`nodes`**: `Array` _Array of Nodes to be removed from graph_\n    - _this is automatically converted to an Array if a single node is passed in._\n\n\n- `.edge([ from ], [ to ], label, properties)`\n  - **`from`** `Array` _Array of Nodes where edge originates_\n  - **`to`**: `Array` _Array of Nodes where edge goes_\n  - **`label`**: `String` _Optional_\n  - **`properties`**: `Object` _Optional_\n\n\n- `.query(label, properties)`\n  - **`label`**: `String` _Optional_\n  - **`properties`**: `Object` _Optional_\n    - you can search for an edge with the property key `_edges`\n  - _An empty query returns all nodes_\n  - _Queries return only their immediate relationships_\n\n\n- `.update([ nodes ], [ labels ], data)`\n  - **`nodes`**: `Array` (or single) node to be updated\n  - **`labels`**: `Array` (or single) label to be added to Nodes.\n  - **`data`**: `Object` Data set to be merged with previous data, any duplicate keys will be overwritten.\n  - _edge labels cannot be updated, an error will be thrown_\n\n## Internal Structure\n\n### Database\n```javascript\n{\n  /**\n   * All relationships with additional properties\n   */\n  edges: [],\n\n  /**\n   * All nodes with properties\n   */\n  nodes: [],\n\n  /**\n   * Dynamic key:value store for tracking known node and edge labels\n   */\n  labels: {\n    nodes: {\n      [label]: [/* Array of Node ids */]\n    },\n    edges: {\n      [label]: [/* Array of Edge ids */]\n    }\n\n  }\n}\n```\n\n### Callback\nThe `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.\n\nThe calls are all identical it is called with the `Type` of request and the modified, added, or removed data.\n\n| method | type     | data                            |\n| ------ | -------- | ------------------------------- |\n| Create | 'create' | `Node`                          |\n| Remove | 'remove' | Array[`Node`]                   |\n| Edge   | 'edge'   | Array[`Edge`]                   |\n| Query  | 'query'  | Array[`Query Result`]           |\n| Update | 'update' | Array[`Updated Nodes / Edges`]  |\n\n### Node\n```javascript\n{\n  identity: \u003cUUID /\u003e,\n  properties: Object,\n  labels: Array,\n  edges: Array,\n}\n```\n\n#### Node information\n- `properties` is the object passed into the `db.create` method.\n- `edges` is an array of Edge identity's before a query, after a query it is an array of references to the `Node`'s they represent\n\n### Edge\n```javascript\n{\n  identity: \u003cUUID /\u003e,\n  from: \u003cNode Identity /\u003e || \u003cNode /\u003e,\n  through: \u003cNode Identity /\u003e || \u003cNode /\u003e,\n  label: String,\n  properties: Object\n}\n```\n\n#### Edge information\n- `properties` is the object passed into the `db.edge` method.\n- `from` and `through` are stored in the DB as `from.identity` and `through.identity`.\n- When `db.query` returns `from` and `through` are references to the `Node`'s they represent\n\n## Coming Features\nCheckout out the [TODO Project](https://github.com/tbremer/Giraffe/projects/1) on Github.\n1. Complex Queries.\n1. Investigate Typescript.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftbremer%2Fgiraffe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftbremer%2Fgiraffe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftbremer%2Fgiraffe/lists"}