开发教程API 文档常见问题Version: 6.4Accessors
- get knex(): Knex<any, any[]>
- get options(): { createForeignKeyConstraints?: boolean; disableForeignKeys?: boolean; ignoreSchema?: string[]; managementDbName?: string }
Returns { createForeignKeyConstraints?: boolean; disableForeignKeys?: boolean; ignoreSchema?: string[]; managementDbName?: string }
optionalcreateForeignKeyConstraints?: boolean
optionaldisableForeignKeys?: boolean
optionalignoreSchema?: string[]
optionalmanagementDbName?: string
Methods
- configureColumn(column: Column, col: ColumnBuilder, knex: Knex<any, any[]>, changedProperties?: Set<string>): ColumnBuilder
Parameters
col: ColumnBuilder
knex: Knex<any, any[]>
optionalchangedProperties: Set<string>
Returns ColumnBuilder
- configureColumnDefault(column: Column, col: ColumnBuilder, knex: Knex<any, any[]>, changedProperties?: Set<string>): ColumnBuilder
Parameters
col: ColumnBuilder
knex: Knex<any, any[]>
optionalchangedProperties: Set<string>
Returns ColumnBuilder
- createCheck(table: CreateTableBuilder, check: CheckDef<unknown>): void
Parameters
table: CreateTableBuilder
Returns void
- createForeignKey(table: CreateTableBuilder, foreignKey: ForeignKey, schema?: string): void
Parameters
table: CreateTableBuilder
optionalschema: string
Returns void
- createIndex(table: CreateTableBuilder, index: IndexDef, tableDef: DatabaseTable, createPrimary?: boolean): void
Parameters
table: CreateTableBuilder
tableDef: DatabaseTable
createPrimary: boolean = false
Returns void
- createSchemaBuilder(schema?: string): SchemaBuilder
Parameters
Returns SchemaBuilder
- createTable(tableDef: DatabaseTable, alter?: boolean): SchemaBuilder
Parameters
tableDef: DatabaseTable
optionalalter: boolean
Returns SchemaBuilder
- createTableColumn(table: TableBuilder, column: Column, fromTable: DatabaseTable, changedProperties?: Set<string>, alter?: boolean): undefined | ColumnBuilder
Parameters
table: TableBuilder
fromTable: DatabaseTable
optionalchangedProperties: Set<string>
optionalalter: boolean
Returns undefined | ColumnBuilder
- databaseExists(connection: Connection, name: string): Promise<boolean>
Parameters
Returns Promise<boolean>
- disableForeignKeysSQL(): string
- dump(builder: string | SchemaBuilder, append: string): Promise<string>
Parameters
builder: string | SchemaBuilder
append: string
Returns Promise<string>
- enableForeignKeysSQL(): string
- finalizeTable(table: TableBuilder, charset: string, collate?: string): void
Parameters
table: TableBuilder
charset: string
optionalcollate: string
Returns void
- getAlterColumnAutoincrement(tableName: string, column: Column, schemaName?: string): string
Parameters
tableName: string
optionalschemaName: string
Returns string
- getAlterNativeEnumSQL(name: string, schema?: string, value?: string, items?: string[], oldItems?: string[]): string
Parameters
name: string
optionalschema: string
optionalvalue: string
optionalitems: string[]
optionaloldItems: string[]
Returns string
- getAlterTable(changedTable: TableDifference, wrap?: boolean): Promise<string>
Parameters
Returns Promise<string>
- getChangeColumnCommentSQL(tableName: string, to: Column, schemaName?: string): string
Parameters
tableName: string
optionalschemaName: string
Returns string
Parameters
tableName: string
optionalschemaName: string
optionalcolumns: Column[]
Returns Promise<CheckDef<unknown>[]>
Parameters
tableName: string
optionalschemaName: string
Returns Promise<Column[]>
- getCreateDatabaseSQL(name: string): string
- getCreateIndexSQL(tableName: string, index: IndexDef, partialExpression?: boolean): string
Parameters
tableName: string
partialExpression: boolean = false
Returns string
- getCreateNamespaceSQL(name: string): string
- getCreateNativeEnumSQL(name: string, values: unknown[], schema?: string): string
Parameters
name: string
values: unknown[]
optionalschema: string
Returns string
- getDatabaseExistsSQL(name: string): string
- getDatabaseNotExistsError(dbName: string): string
- getDefaultEmptyString(): string
- getDropColumnsSQL(tableName: string, columns: Column[], schemaName?: string): string
Parameters
tableName: string
optionalschemaName: string
Returns string
- getDropDatabaseSQL(name: string): string
- getDropIndexSQL(tableName: string, index: IndexDef): string
- getDropNamespaceSQL(name: string): string
- getDropNativeEnumSQL(name: string, schema?: string): string
Parameters
name: string
optionalschema: string
Returns string
Parameters
checks: CheckDef<unknown>[]
tableName: string
optionalschemaName: string
Returns Promise<Dictionary<string[]>>
Parameters
tableName: string
optionalschemaName: string
- getForeignKeysSQL(tableName: string, schemaName?: string): string
Parameters
tableName: string
optionalschemaName: string
Returns string
Parameters
tableName: string
optionalschemaName: string
Returns Promise<IndexDef[]>
- getListTablesSQL(schemaName?: string): string
Parameters
optionalschemaName: string
Returns string
- getManagementDbName(): string
Parameters
Returns Promise<string[]>
Parameters
tableName: string
optionalschemaName: string
Returns Promise<string[]>
- getReferencedTableName(referencedTableName: string, schema?: string): string
Parameters
referencedTableName: string
optionalschema: string
Returns string
- getRenameColumnSQL(tableName: string, oldColumnName: string, to: Column, schemaName?: string): string
Parameters
tableName: string
oldColumnName: string
optionalschemaName: string
Returns string
- getRenameIndexSQL(tableName: string, index: IndexDef, oldIndexName: string): string
Parameters
tableName: string
oldIndexName: string
Returns string
- getSchemaBeginning(charset: string, disableForeignKeys?: boolean): string
Parameters
charset: string
optionaldisableForeignKeys: boolean
Returns string
- getSchemaEnd(disableForeignKeys?: boolean): string
Parameters
optionaldisableForeignKeys: boolean
Returns string
- getTablesGroupedBySchemas(tables: Table[]): Map<undefined | string, Table[]>
Parameters
Returns Map<undefined | string, Table[]>
- hasNonDefaultPrimaryKeyName(table: DatabaseTable): boolean
Parameters
Returns boolean
- inferLengthFromColumnType(type: string): undefined | number
Parameters
Returns undefined | number
- loadInformationSchema(schema: DatabaseSchema, connection: AbstractSqlConnection, tables: Table[], schemas?: string[]): Promise<void>
Parameters
schema: DatabaseSchema
optionalschemas: string[]
Returns Promise<void>
- mapForeignKeys(fks: any[], tableName: string, schemaName?: string): Dictionary
Parameters
fks: any[]
tableName: string
optionalschemaName: string
- normalizeDefaultValue(defaultValue: string, length?: number, defaultValues?: Dictionary<string[]>): string | number
Parameters
defaultValue: string
optionallength: number
defaultValues: Dictionary<string[]> = {}
Returns string | number
- pushTableQuery(table: TableBuilder, expression: string, grouping?: string): void
Parameters
table: TableBuilder
expression: string
grouping: string = 'alterTable'
Returns void
- splitTableName(name: string): [undefined | string, string]
Parameters
Returns [undefined | string, string]
- supportsSchemaConstraints(): boolean
Uses
raw
method injected inAbstractSqlConnection
to allow adding custom queries inside alter statements.