The second parameter of executeSql contains values to be passed to SQLite as bind parameters. According to the SQLite documentation, such parameters can be positional or named. So I was expecting the following to work:
executeSql(
'select * from Assignment where id = :assignmentId',
{ assignmentId: 42 },
success, error);
However, this doesn't seem to work. How can I use named params with the Cordova SQLite storage plugin?
Named parameters are not part of the Web SQL DRAFT API and also not supported by this plugin.
It would be a nice feature to support. I do not expect to support this in the near future. For future consideration.
This idea is marked as a possible enhancement for discussion. I would consider this to be a major change, especially in the evcore/evplus versions, and it would not be easy to support on the browser platform, which is part of the plan for the next major release in #687. (Clumsy alternative would be to use https://github.com/kripken/sql.js/ to support browser platform, for testing purposes. Not recommended and not guaranteed to work.)
In case you really want this change I would like to do this as part of a possible redesign, possibly based on the evcore implementation and probably with a much simpler JavaScript API (maybe similar to node-sqlite3, Promise-based API should be no problem). I would be happy to send you an estimate within the next few days in case you are interested.
P.S. If desired I would probably implement this change as part of a possible redesign discussed in #548.
This feature is now part of the discussion of an improved API with a redesigned implementation in #862.
+1 For this feature
Most helpful comment
This feature is now part of the discussion of an improved API with a redesigned implementation in #862.