指南 參考 原始碼
public class | source

SQLiteQueryInterface

繼承自

查詢介面 → SQLiteQueryInterface

Sequelize 用來與 SQLite 資料庫溝通的介面

方法摘要

公開方法
public

async addConstraint(tableName: *, options: *)

public

async changeColumn(tableName: *, attributeName: *, dataTypeOrOptions: *, options: *)

一個包裝函式,修正 SQLite 無法變更現有表格欄位的功能。它會先建立表格的備份,然後刪除該表格,並建立一個同名的新表格,但會使用修改後的欄位版本。

public

async describeTable(tableName: *, options: *): *

public

async dropAllTables(options: *)

public

async getForeignKeyReferencesForTable(tableName: *, options: *): *

public

async removeColumn(tableName: *, attributeName: *, options: *)

一個包裝函式,修正 SQLite 無法從現有表格移除欄位的功能。它會先建立表格的備份,然後刪除該表格,並建立一個同名的新表格,但不包含過時的欄位。

public

async removeConstraint(tableName: *, constraintName: *, options: *)

public

async renameColumn(tableName: *, attrNameBefore: *, attrNameAfter: *, options: *)

一個包裝函式,修正 SQLite 無法重新命名現有表格欄位的功能。它會先建立表格的備份,然後刪除該表格,並建立一個同名的新表格,但會使用重新命名的欄位版本。

繼承摘要

來自類別 QueryInterface
public

async addColumn(table: string, key: string, attribute: object, options: object): Promise

在表格中新增一個新的欄位

public

async addConstraint(tableName: string, options: object): Promise

在表格中新增一個約束

public

async addIndex(tableName: string | object, attributes: Array, options: object, rawTablename: string): Promise

在欄位中新增索引

public

async bulkDelete(tableName: string, where: object, options: object, model: Model): Promise

從表格中刪除多筆記錄

public

async bulkInsert(tableName: string, records: Array, options: object, attributes: object): Promise

將多筆記錄插入表格

public

async bulkUpdate(tableName: string, values: object, identifier: object, options: object, attributes: object): Promise

更新表格中的多筆記錄

public

async changeColumn(tableName: string, attributeName: string, dataTypeOrOptions: object, options: object): *

變更欄位定義

public

async createDatabase(database: string, options: object): Promise

建立資料庫

public

async createFunction(functionName: string, params: Array, returnType: string, language: string, body: string, optionsArray: Array, options: object): Promise

建立 SQL 函式

public

async createSchema(schema: string, options: object): Promise

建立綱要

public

async createTable(tableName: string, attributes: object, options: object, model: Model): Promise

使用給定的屬性集建立表格

public

async describeTable(tableName: string, options: object): Promise<object>

描述表格結構

public

async dropAllSchemas(options: object): Promise

刪除所有綱要

public

async dropAllTables(options: object): Promise

從資料庫中刪除所有表格

public

async dropDatabase(database: string, options: object): Promise

刪除資料庫

public

async dropFunction(functionName: string, params: Array, options: object): Promise

刪除 SQL 函式

public

async dropSchema(schema: string, options: object): Promise

刪除綱要

public

async dropTable(tableName: string, options: object): Promise

從資料庫中刪除表格

public

async getForeignKeyReferencesForTable(tableName: string, options: object): *

取得表格的外鍵參考詳細資訊

public

async getForeignKeysForTables(tableNames: string[], options: object): Promise

傳回所請求表格的所有外鍵約束

public

quoteIdentifier(identifier: string, force: boolean): string

將識別符號列表以 "." 分割並引用每個部分

public

quoteIdentifiers(identifiers: string): string

將識別符號列表以 "." 分割並引用每個部分。

public

async removeColumn(tableName: string, attributeName: string, options: object): *

從表格中移除欄位

public

async removeConstraint(tableName: string, constraintName: string, options: object): *

從表格中移除約束

public

async removeIndex(tableName: string, indexNameOrAttributes: string | string[], options: object): Promise

從表格中移除已存在的索引

public

async renameColumn(tableName: string, attrNameBefore: string, attrNameAfter: string, options: object): Promise

重新命名欄位

public

async renameFunction(oldFunctionName: string, params: Array, newFunctionName: string, options: object): Promise

重新命名 SQL 函數

public

async renameTable(before: string, after: string, options: object): Promise

重新命名表格

public

async showAllSchemas(options: object): Promise<Array>

顯示所有綱要

public

async tableExists(tableName: TableName, options: QueryOptions): Promise<boolean>

傳回一個 Promise,如果表格存在於資料庫中則解析為 true,否則解析為 false。

public

async upsert(tableName: string, insertValues: object, updateValues: object, where: object, options: object): Promise<boolean, ?number>

Upsert(更新或插入)

公開方法

public async addConstraint(tableName: *, options: *) source

在表格中新增一個約束

可用的約束

  • UNIQUE(唯一)
  • DEFAULT (僅限 MSSQL)
  • CHECK (MySQL - 資料庫引擎忽略)
  • FOREIGN KEY(外鍵)
  • PRIMARY KEY(主鍵)

覆寫

QueryInterface#addConstraint

參數

名稱類型屬性描述
tableName *
options *

public async changeColumn(tableName: *, attributeName: *, dataTypeOrOptions: *, options: *) source

一個包裝函式,修正 SQLite 無法變更現有表格欄位的功能。它會先建立表格的備份,然後刪除該表格,並建立一個同名的新表格,但會使用修改後的欄位版本。

覆寫

QueryInterface#changeColumn

參數

名稱類型屬性描述
tableName *
attributeName *
dataTypeOrOptions *
options *

public async describeTable(tableName: *, options: *): * source

描述表格結構

此方法傳回一個雜湊陣列,其中包含表格中所有屬性的相關資訊。

{
   name: {
     type:         'VARCHAR(255)', // this will be 'CHARACTER VARYING' for pg!
     allowNull:    true,
     defaultValue: null
   },
   isBetaMember: {
     type:         'TINYINT(1)', // this will be 'BOOLEAN' for pg!
     allowNull:    false,
     defaultValue: false
   }
}

覆寫

QueryInterface#describeTable

參數

名稱類型屬性描述
tableName *
options *

傳回

*

public async dropAllTables(options: *) source

從資料庫中刪除所有表格

覆寫

QueryInterface#dropAllTables

參數

名稱類型屬性描述
options *

public async getForeignKeyReferencesForTable(tableName: *, options: *): * source

取得表格的外鍵參考詳細資訊

這些詳細資訊包含 constraintSchema、constraintName、constraintCatalog tableCatalog、tableSchema、tableName、columnName、referencedTableCatalog、referencedTableCatalog、referencedTableSchema、referencedTableName、referencedColumnName。提醒:如果是 sqlite,則不會傳回約束資訊。

覆寫

QueryInterface#getForeignKeyReferencesForTable

參數

名稱類型屬性描述
tableName *
options *

傳回

*

public async removeColumn(tableName: *, attributeName: *, options: *) source

一個包裝函式,修正 SQLite 無法從現有表格移除欄位的功能。它會先建立表格的備份,然後刪除該表格,並建立一個同名的新表格,但不包含過時的欄位。

覆寫

QueryInterface#removeColumn

參數

名稱類型屬性描述
tableName *
attributeName *
options *

public async removeConstraint(tableName: *, constraintName: *, options: *) source

從表格中移除約束

覆寫

QueryInterface#removeConstraint

參數

名稱類型屬性描述
tableName *
constraintName *
options *

public async renameColumn(tableName: *, attrNameBefore: *, attrNameAfter: *, options: *) source

一個包裝函式,修正 SQLite 無法重新命名現有表格欄位的功能。它會先建立表格的備份,然後刪除該表格,並建立一個同名的新表格,但會使用重新命名的欄位版本。

覆寫

QueryInterface#renameColumn

參數

名稱類型屬性描述
tableName *
attrNameBefore *
attrNameAfter *
options *