Methods
escId(s) → {String}
- Description:
轉為Jet之識別字(資料表名、欄位名)
註: Access以中括號引用識別字,其內不支援跳脫,故一律移除中括號字元
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
s |
String | 輸入識別字字串 |
Returns:
回傳Jet識別字字串
- Type
- String
escVal(v) → {String}
- Description:
轉為Jet之值常值
註: 字串以單引號包覆,內部單引號以連續兩個單引號跳脫(Jet之標準跳脫方式) 註: 不可用N'...'前綴,該為SQL Server語法,Jet不支援 註: 日期物件以#...#表示,字串則維持引號由Jet自行隱式轉換
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
v |
* | 輸入值 |
Returns:
回傳Jet值常值字串
- Type
- String
getDeleteAll(tableName) → {String}
- Description:
產生清空全表語句
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
tableName |
String | 輸入資料表名稱字串 |
Returns:
回傳SQL字串
- Type
- String
getDeleteByPk(tableName, pk, pkv) → {String}
- Description:
產生依主鍵刪除語句
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
tableName |
String | 輸入資料表名稱字串 |
pk |
String | 輸入主鍵欄位名字串 |
pkv |
String | Number | 輸入主鍵值 |
Returns:
回傳SQL字串
- Type
- String
getDeleteByPks(tableName, pk, pkvs) → {String}
- Description:
產生依主鍵清單刪除語句
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
tableName |
String | 輸入資料表名稱字串 |
pk |
String | 輸入主鍵欄位名字串 |
pkvs |
Array | 輸入主鍵值陣列 |
Returns:
回傳SQL字串,清單為空時回傳null
- Type
- String
getInsert(tableName, cols, data) → {String}
- Description:
產生插入語句
註: Access不支援一次插入多組VALUES,故一次僅處理一筆
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
tableName |
String | 輸入資料表名稱字串 |
cols |
Array | 輸入資料表欄位名陣列 |
data |
Object | 輸入數據物件 |
Returns:
回傳SQL字串
- Type
- String
getSelectAll(tableName) → {String}
- Description:
產生全表查詢語句
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
tableName |
String | 輸入資料表名稱字串 |
Returns:
回傳SQL字串
- Type
- String
getSelectByPk(tableName, pk, pkv) → {String}
- Description:
產生依主鍵查詢語句
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
tableName |
String | 輸入資料表名稱字串 |
pk |
String | 輸入主鍵欄位名字串 |
pkv |
String | Number | 輸入主鍵值 |
Returns:
回傳SQL字串
- Type
- String
getSelectByPks(tableName, pk, pkvs) → {String}
- Description:
產生依主鍵清單查詢語句,僅取主鍵欄位
註: 供insert於偵測到重複鍵錯誤後,核對該些主鍵是否確實已存在, 藉以區辨[主鍵已存在]與[撞及其他唯一索引],因Jet之錯誤碼3022涵蓋兩者
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
tableName |
String | 輸入資料表名稱字串 |
pk |
String | 輸入主鍵欄位名字串 |
pkvs |
Array | 輸入主鍵值陣列 |
Returns:
回傳SQL字串,清單為空時回傳null
- Type
- String
getUpdate(tableName, cols, data, pk, pkv) → {String}
- Description:
產生依主鍵更新語句
註: 主鍵欄位不納入SET,避免更新時改動主鍵本身
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
tableName |
String | 輸入資料表名稱字串 |
cols |
Array | 輸入資料表欄位名陣列 |
data |
Object | 輸入數據物件 |
pk |
String | 輸入主鍵欄位名字串 |
pkv |
String | Number | 輸入主鍵值 |
Returns:
回傳SQL字串,無可更新欄位時回傳null
- Type
- String
(async) importModels(fdModels, sequelize, name, optopt) → {Promise}
- Description:
匯入資料表設定檔
- Source:
Parameters:
| Name | Type | Attributes | Default | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
fdModels |
String | 輸入models所在資料夾字串 |
|||||||||||||||||
sequelize |
Object | 輸入sequelize實例 |
|||||||||||||||||
name |
String | 輸入資料表名稱字串 |
|||||||||||||||||
opt |
Object |
<optional> |
{}
|
輸入設定物件 Properties
|
Returns:
回傳Promise,resolve回傳models物件,reject回傳錯誤訊息
- Type
- Promise
(async) initSequelize(opt) → {Promise}
- Description:
初始化sequelize
註: 本實例僅用於由sequelize產生SQL文字(見getCmd.mjs), 實際數據操作一律交Jet引擎, 故其資料表為記憶體sqlite且不承載任何數據
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
opt |
Object | 輸入設定物件 |
Returns:
回傳Promise,resolve回傳{sequelize,mds}
- Type
- Promise
jetOpen(dbopt) → {Object}
Parameters:
| Name | Type | Attributes | Default | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
db |
Object |
<optional> |
{}
|
輸入資料庫設定物件 Properties
|
Returns:
回傳操作物件{run,query,execute,create}
- Type
- Object
(async) queryMemory(opt, attrs, data, useFind) → {Promise}
- Description:
於記憶體內過濾數據
因Access之SQL方言不支援$in、$nin、$regex等條件,故由Jet取回全部數據後於記憶體sqlite內過濾
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
opt |
Object | 輸入設定物件 |
attrs |
Object | 輸入資料表欄位定義物件,取自model之rawAttributes |
data |
Array | 輸入待過濾之數據陣列 |
useFind |
Object | 輸入已轉譯為sequelize運算子之查詢條件物件 |
Returns:
回傳Promise,resolve回傳過濾後之數據陣列
- Type
- Promise