{"id":13452084,"url":"https://github.com/sqorn/sqorn","last_synced_at":"2025-10-02T01:31:16.288Z","repository":{"id":52492423,"uuid":"141848063","full_name":"sqorn/sqorn","owner":"sqorn","description":"A Javascript library for building SQL queries","archived":true,"fork":false,"pushed_at":"2023-02-07T16:49:27.000Z","size":1536,"stargazers_count":1871,"open_issues_count":13,"forks_count":49,"subscribers_count":37,"default_branch":"main","last_synced_at":"2025-01-17T13:28:38.151Z","etag":null,"topics":["javascript","nodejs","postgres","postgresql","query-builder","sql","sql-query-builder","tagged-template-literals","template-strings"],"latest_commit_sha":null,"homepage":"https://sqorn.org","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/sqorn.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2018-07-21T21:50:30.000Z","updated_at":"2025-01-11T01:34:56.000Z","dependencies_parsed_at":"2023-02-19T20:15:40.547Z","dependency_job_id":null,"html_url":"https://github.com/sqorn/sqorn","commit_stats":null,"previous_names":[],"tags_count":52,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqorn%2Fsqorn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqorn%2Fsqorn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqorn%2Fsqorn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqorn%2Fsqorn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sqorn","download_url":"https://codeload.github.com/sqorn/sqorn/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234902726,"owners_count":18904521,"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":["javascript","nodejs","postgres","postgresql","query-builder","sql","sql-query-builder","tagged-template-literals","template-strings"],"created_at":"2024-07-31T07:01:12.302Z","updated_at":"2025-10-02T01:31:10.934Z","avatar_url":"https://github.com/sqorn.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","📦 Legacy \u0026 Inactive Projects"],"sub_categories":[],"readme":"# [\u003cimg src=\"https://raw.githubusercontent.com/sqorn/sqorn/master/docs/website/static/img/logo_blue.svg?sanitize=true\" height=\"38px\"/\u003e \u003cspan style=\"color: #2979f\"\u003eSqorn\u003c/span\u003e](https://sqorn.org) \u0026middot; [![License](https://img.shields.io/github/license/sqorn/sqorn.svg)](https://github.com/sqorn/sqorn/blob/master/LICENSE) [![npm](https://img.shields.io/npm/v/sqorn.svg)](https://www.npmjs.com/package/sqorn) ![Supports Node 8+](https://img.shields.io/node/v/sqorn.svg) [![npm](https://img.shields.io/travis/sqorn/sqorn.svg)](https://travis-ci.org/sqorn/sqorn) [![Coverage Status](https://coveralls.io/repos/github/sqorn/sqorn/badge.svg)](https://coveralls.io/github/sqorn/sqorn)\n\nSqorn is a Javascript library for building SQL queries.\n\n**Composable:** Build complex queries from simple parts. Chain, extend, and embed queries.\n\n**Intuitive**: Sqorn's use of modern Javascript language features like tagged template literals and promises makes building and issuing SQL queries a breeze.\n\n**Concise:** Sqorn provides concise syntax for common CRUD operations.\n\n[**Fast:**](https://sqorn.org/benchmarks.html) 10x faster than [Knex.js](https://knexjs.org/) and 200x faster than [Squel](https://github.com/hiddentao/squel)\n\n**Secure:** Sqorn generates parameterized queries safe from SQL injection. Sqorn has no external dependencies.\n\n## Install\n\nSqorn requires Node version 8 or above.\n\n```sh\nnpm install --save @sqorn/pg # only Postgres is currently supported\n```\n\nThen read the [tutorial](https://sqorn.org/docs/tutorial.html) and [try the online demo](https://sqorn.org/demo.html).\n\n## Examples\n\nCRUD Operations are dead simple.\n\n```js\nconst sq = require('@sqorn/pg')()\n\nconst Person = sq`person`, Book = sq`book`\n\n// SELECT\nconst children = await Person`age \u003c ${13}`\n// \"select * from person where age \u003c 13\"\n\n// DELETE\nconst [deleted] = await Book.delete({ id: 7 })`title`\n// \"delete from book where id = 7 returning title\"\n\n// INSERT\nawait Person.insert({ firstName: 'Rob' })\n// \"insert into person (first_name) values ('Rob')\"\n\n// UPDATE\nawait Person({ id: 23 }).set({ name: 'Rob' })\n// \"update person set name = 'Rob' where id = 23\"\n\n```\n\nBuild complex queries from simple parts.\n\n```js\n// CHAIN QUERIES\nsq.from`book`\n  .return`distinct author`\n  .where({ genre: 'Fantasy' })\n  .where({ language: 'French' })\n// select distinct author from book\n// where language = 'French' and genre = 'Fantasy'\n\n// EXTEND QUERIES\nsq.extend(\n  sq.from`book`,\n  sq.return`distinct author`,\n  sq.where({ genre: 'Fantasy' }),\n  sq.where({ language: 'French' })\n)\n// select distinct author from book\n// where language = 'French' and genre = 'Fantasy'\n\n// EMBED Queries\nsq.return`now() today, (${sq.return`now() + '1 day'`}) tomorrow`\n// select now() today, (select now() + '1 day') tomorrow\n```\n\nLearn more in the [tutorial](https://sqorn.org/docs/tutorial.html).\n\n## Contributing\n\nSqorn is a monorepo managed with npm workspaces.\n\nClone the repo then run the following commands to install all dependencies:\n\n```sh\nnpm install\n```\n\n`npm test` runs all tests. `npm run clean` removes all dependencies.\n\nTo run tests that connect to Postgres, you need a running postgres instance from somewhere. Then, you need to set the standard Postgres environment variables to tell the tests where to connect. If you add a `.env` file to this repo, the tests will use environment variables from there to connect.\n\n```\n// in `.env`\nPGHOST=127.0.0.1\nPGUSER=some-user\nPGPASSWORD=some-password\nPGPORT=5432\nPGDATABASE=postgres\n```\n\n## Maintainers\n\nSqorn is currently maintained by the @gadgetinc development team. Please direct support requests, bug reports, and other communication about Sqorn to this github repo.\n\nSqorn was originally created and maintained by @eejdoowad. Thanks to Sufyan for all their hard work creating the project!\n## License\n\nMIT Licensed, Copyright (c) 2018 Sufyan Dawoodjee\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqorn%2Fsqorn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsqorn%2Fsqorn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqorn%2Fsqorn/lists"}