网页
综合
更新时间 2026-06-26 14:59:48
Knex Query Builder | Knex.js
自动蜘蛛
knexjs.org
正文约 2304 字
acquireConnectionTimeout
defaultDateTimePrecision
only (knex/from option) PG only
withRecursive MYCRRS
withMaterialized PG+SQ only
withNotMaterialized PG+SQ only
forUpdate PG+MY only
forNoKeyUpdate PG only
skipLocked PG+MY only
hintComment MY+OR only
Extending Query Builder
whereJsonSupersetOf SQMSORRS
whereJsonSubsetOf SQMSORRS
crossJoin conditions MY+SQ only
createViewOrReplace ~SQ
createMaterializedView MYSQMS
refreshMaterializedView MYSQMS
dropMaterializedView MYSQMS
dropMaterializedViewIfExists MYSQMS
createSchema PG only
createSchemaIfNotExists PG only
dropSchemaIfExists PG only
localCheckOption SQMSORCR
cascadedCheckOption SQMSORCR
Named bindings with array values
Environment configuration
Custom migration name
Generated migration extension
Knexfile in other languages
Transactions in migrations
Webpack migration source example
ECMAScript modules (ESM) Interoperability
The heart of the library, the knex query builder is the interface used for building and executing standard SQL queries, such as select, insert, update, delete.
In many places in APIs identifiers like table name or column name can be passed to methods.
Most commonly one needs just plain tableName.columnName, tableName or columnName, but in many cases one also needs to pass an alias how that identifier is referred later on in the query.
There are two ways to declare an alias for identifier. One can directly give as aliasName suffix for the identifier (e.g. identifierName as aliasName) or one can pass an object { aliasName: 'identifierName' }.
If the object has multiple aliases { alias1: 'identifier1', alias2: 'identifier2' }, then all the aliased identifiers are expanded to comma separated list.
Identifier syntax has no place for selecting schema, so if you are doing schemaName.tableName, query might be rendered wrong. Use .withSchema('schemaName') instead.
knex(tableName, options)knex.[methodName]
The query builder starts off either by specifying a tableName you wish to query against, or by calling any method directly on the knex object. This kicks off a jQuery-like chain, with which you can call additional query builder methods as needed to construct the query, eventually calling any of the interface methods, to either convert toString, or execute the query with a promise, callback, or stream.
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。