TypeScript 中 Uint8Array 类型变量的可能值是多少?
What is a possible value for a Uint8Array typed variable in TypeScript?
如果接口内的变量类型为 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
格式的数据库是什么样的呢?
它不是数据库 name。它是一个 数据库 。阅读 sql.js 是什么会告诉你它是通过 Emscripten 编译成 JavaScript 的 SQLite,带有 in-memory 存储。默认情况下,它会给你一个空白的数据库,当你停止使用它时,它就会被遗忘;但是您可以选择将其导入或导出到 Uint8Array
,这实际上是 SQLite 数据库文件的 byte-by-byte 内容。查看 sql.js readme 以查看有关如何获取数据库数组的许多示例(来自上传、来自 XHR、来自 Node.js 读取文件...)。
如果接口内的变量类型为 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
格式的数据库是什么样的呢?
它不是数据库 name。它是一个 数据库 。阅读 sql.js 是什么会告诉你它是通过 Emscripten 编译成 JavaScript 的 SQLite,带有 in-memory 存储。默认情况下,它会给你一个空白的数据库,当你停止使用它时,它就会被遗忘;但是您可以选择将其导入或导出到 Uint8Array
,这实际上是 SQLite 数据库文件的 byte-by-byte 内容。查看 sql.js readme 以查看有关如何获取数据库数组的许多示例(来自上传、来自 XHR、来自 Node.js 读取文件...)。