Class OperationNodeTransformer

Transforms an operation node tree into another one.

Kysely queries are expressed internally as a tree of objects (operation nodes). OperationNodeTransformer takes such a tree as its input and returns a transformed deep copy of it. By default the OperationNodeTransformer does nothing. You need to override one or more methods to make it do something.

There's a method for each node type. For example if you'd like to convert each identifier (table name, column name, alias etc.) from camelCase to snake_case, you'd do something like this:

class CamelCaseTransformer extends OperationNodeTransformer {
transformIdentifier(node: IdentifierNode): IdentifierNode {
node = super.transformIdentifier(node),

return {
...node,
name: snakeCase(node.name),
}
}
}

const transformer = new CamelCaseTransformer()
const tree = transformer.transformNode(tree)

Hierarchy

  • OperationNodeTransformer

Constructors

Properties

Methods

transformAddColumn transformAddConstraint transformAddIndex transformAggregateFunction transformAlias transformAlterColumn transformAlterTable transformAnd transformBinaryOperation transformCase transformCast transformCheckConstraint transformColumn transformColumnDefinition transformColumnUpdate transformCommonTableExpression transformCommonTableExpressionName transformCreateIndex transformCreateSchema transformCreateTable transformCreateType transformCreateView transformDataType transformDefaultInsertValue transformDefaultValue transformDeleteQuery transformDropColumn transformDropConstraint transformDropIndex transformDropSchema transformDropTable transformDropType transformDropView transformExplain transformFetch transformForeignKeyConstraint transformFrom transformFunction transformGenerated transformGroupBy transformGroupByItem transformHaving transformIdentifier transformInsertQuery transformJSONOperatorChain transformJSONPath transformJSONPathLeg transformJSONReference transformJoin transformLimit transformList transformMatched transformMergeQuery transformModifyColumn transformNode transformNodeImpl transformNodeList transformOffset transformOn transformOnConflict transformOnDuplicateKey transformOperator transformOr transformOrderBy transformOrderByItem transformOver transformParens transformPartitionBy transformPartitionByItem transformPrimaryKeyConstraint transformPrimitiveValueList transformRaw transformReference transformReferences transformRenameColumn transformReturning transformSchemableIdentifier transformSelectAll transformSelectModifier transformSelectQuery transformSelection transformSetOperation transformTable transformTop transformTuple transformUnaryOperation transformUniqueConstraint transformUpdateQuery transformUsing transformValue transformValueList transformValues transformWhen transformWhere transformWith

Constructors

Properties

nodeStack: OperationNode[] = []

Methods

Generated using TypeDoc