SQLite3是否在Node.js中准备了语​​句?

问题描述:

在npm文档中,只有可见的准备好的语句才能插入.这些准备好的语句对选择,更新和删除有效吗?

From the npm docs, only visible prepared statements are for insert. Does these prepared statement work for Select, update, and delete?

我尝试进行选择,没有 .each 函数,其中的行被回调.任何人都可以做到这一点或拥有指向资源的链接,因为我敢肯定找不到任何东西.

I tried for select, there isn't a .each function where the rows are called back. Anyone been able to do this or have links to resources, cause I can sure as hell unable to find any.

根据 node-sqlite3 API文档,您可以通过几种不同的方式在SQL查询中使用参数:

According to the node-sqlite3 API documentation, you can use parameters in your SQL queries in several different ways:

// Directly in the function arguments.
db.run("UPDATE tbl SET name = ? WHERE id = ?", "bar", 2);

// As an array.
db.run("UPDATE tbl SET name = ? WHERE id = ?", [ "bar", 2 ]);

// As an object with named parameters.
db.run("UPDATE tbl SET name = $name WHERE id = $id", {
  $id: 2,
  $name: "bar"
});