Composable: Build complex queries from simple parts. Chain, extend, and embed queries.
Concise: Sqorn provides concise syntax for common CRUD operations.
Secure: Sqorn generates parameterized queries safe from SQL injection. Sqorn has no external dependencies.
Sqorn requires Node version 8 or above.
npm install --save @sqorn/pg # only Postgres is currently supported
CRUD Operations are dead simple.
const sq =const Person = sq`person` Book = sq`book`// SELECTconst children = await Person`age < `// "select * from person where age < 13"// DELETEconst deleted = await Book`title`// "delete from book where id = 7 returning title"// INSERTawait Person// "insert into person (first_name) values ('Rob')"// UPDATEawait// "update person set name = 'Rob' where id = 23"
Build complex queries from simple parts.
// CHAIN QUERIESsqfrom`book`return`distinct author`// select distinct author from book// where language = 'French' and genre = 'Fantasy'// EXTEND QUERIESsq// select distinct author from book// where language = 'French' and genre = 'Fantasy'// EMBED Queriessqreturn`now() today, () tomorrow`// select now() today, (select now() + '1 day') tomorrow
Learn more in the tutorial.
MIT Licensed, Copyright (c) 2018 Sufyan Dawoodjee