knex
约 2 分钟阅读
- knexGitHubknex/knexcomposite - 解耦构建最终 query 的过程 · 对于基础的访问模式提供跨库支持 · knex-types 基于 db schema 生成 ts · 参考 · kysely · Knex QueryLab · Knex to SQL笔记:knex
- composite - 解耦构建最终 query 的过程
- 对于基础的访问模式提供跨库支持
- knex-types 基于 db schema 生成 ts
- 参考
- kysely笔记Kyselyknex 会尝试适配不同 dialect, 提供相同的语义 · e.g. MSSQL 可以使用 limit · 因此 knex 相对更复杂 · kysely 要求用户自己熟悉各种 SQL 语法 · e.g. MSSQL 使用 top, 虽然有 limit 接口,但是生成的语法是错误的打开:/notes/web/framework/kysely
- Knex QueryLabLinkmichaelavila.com/knex-querylabcomposite - 解耦构建最终 query 的过程 · 对于基础的访问模式提供跨库支持 · knex-types 基于 db schema 生成 ts · 参考 · kysely · Knex QueryLab · Knex to SQL笔记:knex
- Knex to SQL
- pool
- 默认
min: 2, max: 10 - 推荐 min 0
- 使用 vincit/tarn.jsGitHubvincit/tarn.js
- 默认
const pool = new Pool({
// 最小 2 - 推荐 0
min: 2,
// 最大 - 根据场景性能要求调整
max: 10,
// acquire promises are rejected after this many milliseconds
// if a resource cannot be acquired
acquireTimeoutMillis: 30000,
// create operations are cancelled after this many milliseconds
// if a resource cannot be acquired
createTimeoutMillis: 30000,
// destroy operations are awaited for at most this many milliseconds
// new resources will be created after this timeout
destroyTimeoutMillis: 5000,
// Free resources are destroyed after this many milliseconds.
// Note that if min > 0, some resources may be kept alive for longer.
// To reliably destroy all idle resources, set min to 0.
idleTimeoutMillis: 30000,
// how often to check for idle resources to destroy
reapIntervalMillis: 1000,
// how long to idle after failed create before trying again
createRetryIntervalMillis: 200,
// If true, when a create fails, the first pending acquire is
// rejected with the error. If this is false (the default) then
// create is retried until acquireTimeoutMillis milliseconds has
// passed.
propagateCreateError: false,
});const db = knex({
client: 'better-sqlite3',
connection: {
filename: 'test.sqlite3',
},
useNullAsDefault: true,
});
db.raw('PRAGMA journal_mode = WAL');FAQ
raw in
- 用
=any(?) - pg 的 in 不支持 array
- knex/knex#2053 (comment)GitHub Issueknex/knex#2053
- knex/knex#1537 (comment)GitHub Issueknex/knex#1537
- knex/knex#1537GitHub Issueknex/knex#1537
Reference Snippets
knex/knex#3186GitHub Issueknex/knex#3186
Crossdb support for INSERT ... ON CONFLICT / MERGE upsert
- knex 的核心理念是 composite - 解耦构建最终 query 的过程
- 对于基础的访问模式提供跨库支持
- knex-types 基于 db schema 生成 ts
关联信息
反向链接和本文引用的外部资料。
反向链接
- Kysely笔记 · Knex.js
knex 会尝试适配不同 dialect, 提供相同的语义 · e.g. MSSQL 可以使用 limit · 因此 knex 相对更复杂 · kysely 要求用户自己熟悉各种 SQL 语法 · e.g. MSSQL 使用 top, 虽然有 limit 接口,但是生成的语法是错误的
References
GitHub
5 条- knex/knex#1537github.com/knex/knex/issues/1537
- knex/knexgithub.com/knex/knex
- knex/knex#2053github.com/knex/knex/issues/2053
- knex/knex#3186github.com/knex/knex/issues/3186
- vincit/tarn.jsgithub.com/vincit/tarn.js
其他外链
2 条- medium.com/p/bf410349856c/responses/showmedium.com/p/bf410349856c/responses/show
- michaelavila.com/knex-querylabmichaelavila.com/knex-querylab