{"id":15497368,"url":"https://github.com/heapwolf/level-sql","last_synced_at":"2025-08-08T20:03:31.446Z","repository":{"id":11440385,"uuid":"13897133","full_name":"heapwolf/level-sql","owner":"heapwolf","description":"sql for nosql [a work in progress, contributors welcome!]","archived":false,"fork":false,"pushed_at":"2013-10-28T01:03:13.000Z","size":204,"stargazers_count":19,"open_issues_count":2,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-29T19:34:30.324Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/heapwolf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-10-27T06:53:25.000Z","updated_at":"2020-10-22T09:43:37.000Z","dependencies_parsed_at":"2022-09-13T13:12:26.645Z","dependency_job_id":null,"html_url":"https://github.com/heapwolf/level-sql","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/heapwolf%2Flevel-sql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heapwolf%2Flevel-sql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heapwolf%2Flevel-sql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heapwolf%2Flevel-sql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/heapwolf","download_url":"https://codeload.github.com/heapwolf/level-sql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250333781,"owners_count":21413459,"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":[],"created_at":"2024-10-02T08:33:13.328Z","updated_at":"2025-04-22T22:29:57.350Z","avatar_url":"https://github.com/heapwolf.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MOTIVATION\nSo you are happy with your very small, very fast key value store. \nBut now for some reason you think you need SQL. Ok, fine. Here is \na module.\n\n# USAGE\nGiven the following key/values\n```\nkey1  { a: 0, b: 1 }\nkey2  { a: 2, b: 3 } \n```\n\nAnd some boilerplate\n```js\nvar level = require('level');\nvar sql = require('level-sql');\n\nvar db = level('./db', { valueEncoding: 'json' });\nsql(db);\n```\n\n### Select Any\nGiven a table T, the query `SELECT * FROM T` will result in all \nthe elements of all the rows of the table being shown.\n```js\nvar stream1 = db.query('SELECT * from table1');\n```\n\n```json\n{ \"key\": \"key1\", \"value\": { \"a\": 0, \"b\": 1 } }\n{ \"key\": \"key2\", \"value\": { \"a\": 2, \"b\": 3 } }\n```\n\n### Select Specific\nWith the same table, the query `SELECT K FROM T` will result in \nthe elements from the key `K` of all the rows of the table being \nshown.\n\n```js\nvar stream1 = db.query('SELECT a from table1');\n```\n\n```json\n{ \"key\": \"key1\", \"value\": { \"a\": 0 } }\n{ \"key\": \"key2\", \"value\": { \"a\": 2 } }\n```\n\n### Where Clauses\nWith the same table, the query `SELECT * FROM T WHERE K1 = 2` will \nresult in all the elements of all the rows where the value of column \n`K1` is `2` being shown — in Relational algebra terms, a selection \nwill be performed, because of the `WHERE` clause. This is also known \nas a Horizontal Partition, restricting rows output by a query \naccording to specified conditions. There can be as many conditions\nas you want separated by `and` or `or`.\n\n```js\nvar stream1 = db.query('SELECT a from table1 WHERE a = 2 and a \u003c\u003e 1');\n```\n\n```json\n{ \"key\": \"key2\", \"value\": { \"a\": 2 } }\n```\n\n# TODO\nThis is a work in progress, and I don't plan to give it a ton \nof attention, if you like this idea ping me and I will add you\nas a contributor.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheapwolf%2Flevel-sql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fheapwolf%2Flevel-sql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheapwolf%2Flevel-sql/lists"}