Uncaught TypeError: must start with number, buffer, array or string
还没有人认领这个 Issue。
- 主要语言
- JavaScript
- 星标
- 13.7k
- 派生
- 1.1k
- PR 合并指标
- 30 天内没有已合并 PR
描述
I've created a little script with sql.js documentation, but i'm unable to write buffer into a.db (Win)
console gives me error: "Uncaught TypeError: must start with number, buffer, array or string"
is that something regarding "var data = db.export();" function or is there something wrong in my code?
var fs = require("fs");
var remote = require('remote');
var SQL = remote.require('sql.js');
var file = "a.db"
var exists = fs.existsSync(file);
if(!exists) {
console.log("DB creation: "+file+ "");
fs.openSync(file, "w");
}
var filebuffer = fs.readFileSync(file);
// Load the db
var db = new SQL.Database(filebuffer);
// Run a query without reading the results
db.run("CREATE TABLE test (col1, col2);");
// Insert two rows: (1,111) and (2,222)
db.run("INSERT INTO test VALUES (?,?), (?,?)", [1,111,2,222]);
var data = db.export();
var buffer = new Buffer(data);
fs.writeFileSync(file, buffer);
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
Start with the shown JavaScript script, focusing on the SQL.Database input and the conversion of db.export() before fs.writeFileSync. Reproduce the TypeError on Windows and verify that the script can create, write, and reopen a.db without the error.
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, node.js, sqlite
- 领域
- database
- Issue 类型
- 缺陷
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100