{"id":21474849,"url":"https://github.com/cbinet/knot-db","last_synced_at":"2025-03-17T07:45:29.208Z","repository":{"id":143868160,"uuid":"154259033","full_name":"CBinet/knot-db","owner":"CBinet","description":"Relationship driven lightweight database","archived":false,"fork":false,"pushed_at":"2018-11-03T03:05:24.000Z","size":106,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-24T10:44:12.444Z","etag":null,"topics":["database","graph","graphs","http","http-server","json","json-format","light","lightweight","nodes","query","query-language","relationship","weight"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/knot-db","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CBinet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-23T03:52:57.000Z","updated_at":"2018-12-16T01:33:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"4decb4d2-5868-4735-8f18-c559cc05366e","html_url":"https://github.com/CBinet/knot-db","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CBinet%2Fknot-db","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CBinet%2Fknot-db/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CBinet%2Fknot-db/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CBinet%2Fknot-db/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CBinet","download_url":"https://codeload.github.com/CBinet/knot-db/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243997037,"owners_count":20380980,"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":["database","graph","graphs","http","http-server","json","json-format","light","lightweight","nodes","query","query-language","relationship","weight"],"created_at":"2024-11-23T10:33:22.252Z","updated_at":"2025-03-17T07:45:29.184Z","avatar_url":"https://github.com/CBinet.png","language":null,"readme":"\u003cimg src=\"https://imgur.com/download/chTnhqw\" style=\"margin-top: 5%; margin-bottom: 5%\"/\u003e\n\n# KnotDatabase\n\n- [Get started](#get-started)\n- [Insert query](#insert-query)\n- [Match query](#match-query)\n- [Update query](#update-query)\n\n***\n\n## Get started\n\n### Installation\n\nRun the following command to install the package\n\n```dos\nnpm install -g knot-db\n```\n\nThen to start the database, you can simply run :\n\n```dos\nknot-db\n```\n\nThe database should now be running on the port specified in the *config.json* file. (***9600** by default*)\n\n### Sending queries\n\nTo query the database, simply send an HTTP **post** request at ```localhost:\u003cPORT\u003e/query``` with a body like the following :\n\n```json\nPOST/query\n{\n    \"table\" : \"employees\",\n    \"query\" : \"MATCH (a:Person {name: 'Marc'}) RETURN a;\"\n}\n```\n\nwhere **table** is the name of the table to apply the query and **query** is the actual query to execute.\n\nA typical response would like this :\n\n```json\n{\n    \"a\": {\n        \"P256\": {\n            \"id\": \"P256\",\n            \"type\": \"Person\",\n            \"attributes\": {\n                \"name\": \"Marc\",\n                \"surname\": \"Davis\",\n                \"sector\": \"Marketing\"\n            },\n            \"relationships\": {\n                \"likes\": [\"P965\"]\n            }\n        },\n        \"P443\": {\n            \"id\": \"P443\",\n            \"type\": \"Person\",\n            \"attributes\": {\n                \"name\": \"Marc\",\n                \"surname\": \"Jones\",\n                \"sector\": \"Sales\",\n                \"intern\": true\n            },\n            \"relationships\": {}\n        }\n    }\n}\n```\n\n***\n\n## Insert query\n\n```js\n// Adds a node 'P001' of type 'Person' with name 'John Doe' who owns node 'B001'.\nINSERT (P001:Person {name: 'John Doe'} {owns: ['B001']});\n```\n\n**Valid Formats**:\n\n- INSERT ( **Id** : **Type** ) ;\n- INSERT ( **Id** : **Type** { **Attributes** } ) ;\n- INSERT ( **Id** : **Type** { **Attributes** } { **Relations** } ) ;\n\n**Id**: Id of the node. Must be unique.  \n*Upper or lower camelcase format required*.\n\n**Type**: Type of the node.  \n*Upper or lower camelcase format required*.\n\n**Attributes**: Attributes of the node.  \n*JSON format required*.\n\n**Relations**: Relations of the node.  \n*JSON format required*.\n\n**Examples**:\n\n```js\n// Inserts a node with id '10001' of type 'Person'.\nINSERT (10001:Person);\n\n// Inserts a node with id '10001' of type 'Person' with name 'Paul Jones'.\nINSERT (10001:Person {name: 'Paul Jones'});\n\n// Inserts a node with id '10001' of type 'Person' with name 'Paul Jones' who likes another node with id '10003'.\nINSERT (10001:Person {name: 'Paul Jones'} {likes: ['10003']});\n```\n\n### Insert Example\n\n```js \nINSERT (P002:Person {name: 'Paul Jones', alive: true, geolocation: [12;23;true;'Québec']} {likes: ['P001'], owns: ['B001';'B002']});\n```\n\n```json\n{\n    \"P002\": {\n        \"id\": \"P002\",\n        \"type\": \"Person\",\n        \"attributes\": {\n            \"name\": \"Paul Jones\",\n            \"alive\": true,\n            \"geolocation\": [\n                12,\n                23,\n                true,\n                \"Québec\"\n            ]\n        },\n        \"relationships\": {\n            \"likes\": [\"P001\"],\n            \"owns\": [\"B001\",\"B002\"]\n        }\n}\n```\n\n***\n\n## Match query\n\n```js \n// Matches all persons from 'Canada' who owns a library.\nMATCH (a:Person {origin: 'Canada'})=[owns]\u003e(b:Building {type: 'library'}) RETURN a;\n```\n\n### Node Selectors\n\n**Valid Formats**:\n\n- MATCH ( **Name** ) ...\n- MATCH ( **Name** : **Type** ) ...\n- MATCH ( **Name** : **Type** { **Criterias** } ) ...\n\n**Name**: Name of the selector. This value is used to identify the selector.  \n*Upper or lower camelcase format required*.\n\n**Type**: Type of the selector. This value is used to filter using the node type.  \nYou can also use the wildcard operator (?) to match any type of node.  \n*Upper or lower camelcase format required*.\n\n**Criterias**: Criterias for selection. This value will be used to filter using the node attributes.  \n*JSON format required*.\n\n**Examples**:\n\n```js \n// Match all of any type\nMATCH (a) RETURN a;\n\n// Match all of type 'Person'\nMATCH (a:Person) RETURN a;\n\n// Match all of type 'Person' with name 'John Doe'\nMATCH (a:Person {name: 'John Doe'}) RETURN a;\n\n// Match all of any type with location 'Québec, Canada'\nMATCH (a:? {location: 'Québec, Canada'}) RETURN a;\n```\n\n### Node Relations\n\n**Valid Formats**:\n\n- MATCH **SourceSelector** =[ **Name** ]\u003e **TargetSelector** ...\n- MATCH **TargetSelector** \u003c[ **Name** ]= **SourceSelector** ...\n\n**SourceSelector**: Source node selector.  \n*See [NodeSelectors](#node-selectors) section above for more details*.\n\n**Name**: Name of the relation. This will be used to filter with the node relationships.  \n*Upper or lower camelcase format required*.\n\n**TargetSelector**: Target node selector.  \n*See [NodeSelectors](#node-selectors) section above for more details*.\n\n**Examples**:\n\n```js \n// Match all of type 'Person' type who 'likes' another 'Person'.\nMATCH (a:Person)=[likes]\u003e(b:Person) RETURN a;\n\n// Match all of type 'Building' type who are owned by a 'Person'.\nMATCH (a:Building)\u003c[owns]=(b:Person) RETURN a;\n\n// Match all of type 'Person' type who 'likes' another 'Person' who owns a 'Building'.\nMATCH (a:Person)=[likes]\u003e(b:Person)=[owns]\u003e(c:Building) RETURN a;\n```\n\n### Returns Statements\n\n**Valid Formats**:\n\n- MATCH ... RETURN **Values** ;\n\n**Values**: Return values. If there is more than one return value, values are separated by a comma.  \n*Values must be equal to one of the [NodeSelectors](#node-selectors) **Name** to be valid*.\n\n**Examples**:\n\n```js \n// Returns the dataset with the selector name 'a'.\nMATCH (a:Person) RETURN a;\n\n// Returns the datasets with the selector names 'a' and 'b'.\nMATCH (a:Person)=[owns]\u003e(b:Building) RETURN a,b;\n```\n\n***\n\n## Update query\n\n```js \n// Update name of node 'P001' to value 'John Doe'\nUPDATE (P001:Person =\u003e {name: 'John Doe'});\n```\n\n**Valid Formats**:\n\n- UPDATE ( **Id** : **Type** =\u003e { **UpdateValue** } ) ;\n- UPDATE ( ? : **Type** =\u003e { **UpdateValue** } ) ;\n- UPDATE ( ? : **Type** { **Criterias** } =\u003e { **UpdateValue** } ) ;\n\n**Id**: Id of the selector. If the value is '?', the query will update all nodes of fitting the **Type** and **Criterias**.  \n*Upper or lower camelcase format required*.\n\n**Type**: Type of the selector. This value is used to filter with the node type.  \n*Upper or lower camelcase format required*.\n\n**Criterias**: Criterias for selection. This value will be used to filter with the node attributes.  \n*JSON format required*.\n\n**UpdateValue**: Properties of the node to update.  \n*JSON format required*.\n\n**Examples**:\n\n```js \n// Updates name of node 'P001' to value 'Paul Jones'.\nUPDATE (P001:Person =\u003e {name: 'Paul Jones'});\n\n// Updates name of all nodes of type 'Person' to value 'Paul Jones'.\nUPDATE (?:Person =\u003e {name: 'Paul Jones'});\n\n// Updates name of all nodes of type 'Person' with name 'Marie Jones' to value 'Paul Jones'.\nUPDATE (?:Person {name: 'Marie Jones'} =\u003e {name: 'Paul Jones'});\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcbinet%2Fknot-db","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcbinet%2Fknot-db","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcbinet%2Fknot-db/lists"}