(1 minute read)
Squel version 1.0.6 is now out. You can now tell Squel to automatically quote table and field names. In addition the query builder options code was refactored and simplified.
How to use
Let's say you build a query:
squel.select()
.from("students")
.field("name", "Student name");
By default this will give you:
SELECT name AS "Student name" FROM students
Now you can pass in the following options:
squel.select({
autoQuoteTableNames: true,
autoQuoteFieldNames: true,
nameQuoteCharacter: '|'
})
.from("students")
.field("name", "Student name");
This will give:
SELECT |name| AS "Student name" FROM |students|
Note: if nameQuoteCharacter is ommitted then ` is assumed to be the quote character.
Download it
Install squel using npm:
$ npm install squel
Homepage: squeljs.org
Github: github.com/hiddentao/squel