如果接口(interface)内的变量类型为 Uint8Array
,可能的值是什么?
typeorm/src/driver/sqljs/SqljsConnectionOptions.ts https://github.com/typeorm/typeorm/blob/master/src/driver/sqljs/SqljsConnectionOptions.ts
/**
* Sql.js-specific connection options.
*/
export interface SqljsConnectionOptions extends BaseConnectionOptions {
/**
* A Uint8Array that gets imported when the connection is opened.
*/
readonly database?: Uint8Array;
}
如果已阅读 MDN's article on Uint8Array
,但没有帮助。
编辑:如您所见,需要一个数据库名称。直觉上我会过去输入数据库的名称,但这是一个字符串。那么 Uint8Array
格式的数据库是什么样的?
最佳答案
它不是数据库名称。它是一个数据库。阅读 sql.js 后,您会发现它是 SQLite 通过 Emscripten 编译成 JavaScript,并具有内存存储。默认情况下,它会给你一个空白数据库,当你停止使用它时,它就会被忘记;但您可以选择从 Uint8Array 导入或导出到 Uint8Array,它实际上是 SQLite 数据库文件的逐字节内容。看sql.js readme查看如何获取数据库数组的许多示例(从上传、从 XHR、从 Node.js 读取文件......)。
关于javascript - TypeScript 中 Uint8Array 类型变量的可能值是多少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48955291/