Comments (7)
I had the same idea a few days ago and thought it would need a babel preprocessor...
Would love to have this !
from node-sqlite.
In the meantime you can use
export const S = (strings, ...values) => [strings.join('?'), values]
db.all(...S`select * from foo where t = ${bar}`).then(...)
But the proposed approach is of course better. Would also be nice to have an id escape mechanism, since you can't pass e.g. table names as parameters. Options: either inline SELECT * FROM id${tableName}
or through magic objects SELECT * FROM ${id(tableName)}
. I think I prefer inline.
from node-sqlite.
@wmertens, would be better to use String objects for enhanced strings...
db.literal = str => Object.assign(new String(str), { literal: true });
then check for a .literal
property on a String
...
if (str intanceof String && str.literal)
But that would be more than a simple join, of course.
from node-sqlite.
True. More obvious, but more typing though ☺
from node-sqlite.
var id = db.literal;
...
db.all(`... ${id(someTableName)} ...`)
Not too bad...
from node-sqlite.
Create a PR w/ unit tests and an updated readme on usage
from node-sqlite.
Will see if I can work on this soon... haven't been working with sqlite lately, so will need to create some test scenarios and get it working.
from node-sqlite.
Related Issues (20)
- json1 extension HOT 1
- Best way to batch create/insert or update? (How to properly use driver.serialize?) HOT 1
- Unable to open DB read only HOT 9
- Can't execute transaction HOT 3
- placeholders don't work with pragma HOT 2
- SQLCipher support HOT 2
- Problem with nullable fields in knex HOT 1
- Placeholders don't work with exec
- Exceptions don't always contain stack traces HOT 3
- The callback error does not work and an exception error is generated! HOT 4
- electron-forge make error HOT 1
- Access sqlite database which has password HOT 1
- migration logic HOT 2
- impossible to change migration configuration HOT 2
- sqlite api to create a db HOT 4
- Date and time in db.run HOT 3
- Getting multiple errors in React TypeScript HOT 1
- bun.sh driver? HOT 2
- Why are sqlite3 typings included here when sqlite3 has its own typings? HOT 9
- Unable to install Sqlite HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-sqlite.