CodeSampleX

示例

bun 1.3.14: Use SQLite from Bun with the built-in bun:sqlite module, with no npm package and no native build

已验证示例 — npm bun 1.3.14: Use SQLite from Bun with the built-in bun:sqlite module, with no npm package and no native build. contract 在 bun 1 · linux alpine/x64…

sha256:6aa79cb39a2ca09b9f9be36d65c6b5ee6b822c96560fc9dee9d80d1840830d1c

本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。 提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。 MIT-0

执行证据

声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。

证据依据
签名契约通过
验证回执
2
构建过它的签名密钥
2
声明的环境 bun 1 linux x64 bun 1 javascript bun

验证运行环境

环境 契约 阶段 运行日期
bun 1 · linux alpine/x64 · docker ed25519:a2ec939a4c60e243 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · npm@1
2026-08-14
bun 1 · linux alpine/x64 · docker ed25519:d91480838ac982c9 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · npm@1
2026-08-18

案例

HOW
目标
Use SQLite from Bun with the built-in bun:sqlite module, with no npm package and no native build
符号
  • bun:sqlite.Database
  • Database.query
  • Database.prepare
  • Statement.get
  • Statement.all
  • Statement.run
  • Statement.safeIntegers
  • SQLiteError
环境
bun 1
创建时间
2026-08-14T12:07:16Z

契约

  1. open ':memory:' and assert each connection is a private database
  2. assert new Database(path, {}) raises SQLITE_MISUSE while new Database(path) works, because an options object resets the open flags, and that only a true access mode or a strict/safeIntegers key restores one, so { create: false } raises the same way
  3. assert .get() returns a plain row object, and null rather than undefined when nothing matches
  4. assert .all() returns an array, and an empty array when nothing matches
  5. assert .run() returns changes and lastInsertRowid and never rows, and that lastInsertRowid is the connection's last insert rather than this statement's
  6. assert ? binding is counted, so a wrong number of values raises
  7. assert $name binding needs the sigil on the key by default, where a bare key silently binds NULL
  8. assert strict: true inverts that, binding bare keys and raising Missing parameter for the $ key
  9. assert binding is real escaping by storing a value that closes a quote and drops the table
  10. assert db.query() returns one cached statement per SQL string while db.prepare() returns a new one, so safeIntegers set on a query() statement leaks to later callers
  11. assert an integer past Number.MAX_SAFE_INTEGER is stored losslessly but read back rounded, and is exact only with safeIntegers, as a BigInt
  12. assert safeIntegers as a constructor option makes every read on the connection exact, including lastInsertRowid, while changes stays a number, and that there is no Database-level safeIntegers toggle
  13. assert a unique constraint raises SQLiteError carrying SQLite's extended result code
  14. assert bun:sqlite is a builtin of the Bun runtime rather than an npm package: the Bun global is present, node:sqlite is not, and the project resolves no dependencies

文件

  • csx.json
  • package.json
  • src/ledger.mjs
  • test/contract.mjs

下载源代码构件 (tar.gz)

原始种子者

anonymous