WOrmMdb

WOrmMdb

new WOrmMdb(optopt) → {Object}

Description:
  • 操作關聯式資料庫

Source:
Parameters:
Name Type Attributes Default Description
opt Object <optional>
{}

輸入設定物件,預設{}

Properties
Name Type Attributes Default Description
url String <optional>
'mdb://username:password'

輸入連接資料庫字串,資料庫僅可選'mdb',預設'mdb://username:password'

storage String <optional>
'./worm.db'

輸入mdb資料庫檔案位置字串,預設'./worm.db'

useEncryption Boolean <optional>
false

輸入是否使用加密保護,型別為布林值,預設false

db String <optional>
'worm'

輸入使用資料庫名稱字串,mdb並不需要給只是配合w-orm系列統一設定,預設'worm'

cl String <optional>
'test'

輸入使用資料表名稱字串,預設'test'

fdModels String <optional>
'./models'

輸入資料表設定檔所在資料夾字串,預設'./models'

dbType String <optional>
'Access2007'

輸入使用資料庫類型字串,可選'Access2000-2003'、'Access2007',預設'Access2007'

modelType String <optional>
'js'

輸入資料表設定檔類型字串,可有'js'、'json',預設'js'

logging Boolean <optional>
false

輸入是否輸出實際執行的sql指令布林值,預設false

pk String <optional>
'id'

輸入數據主鍵字串,預設'id'

autoGenPK Boolean <optional>
true

輸入若數據pk(id)欄位沒給時則自動給予隨機uuid,型別為布林值,預設true

useStable Boolean <optional>
true

輸入是否使用穩定模式,使用佇列管理同時只能進行一種操作故會犧牲效能,mdb需開啟穩定模式才不會有非預期錯誤,型別為布林值,預設true

Returns:

回傳操作資料庫物件,各事件功能詳見說明

Type
Object

Methods

(async, static) createStorage() → {Promise}

Description:
  • 創建mdb資料庫檔案

Source:
Returns:

回傳Promise,resolve回傳創建結果,reject回傳錯誤訊息

Type
Promise

(async, static) del(data, optionopt) → {Promise}

Description:
  • 刪除數據

Source:
Parameters:
Name Type Attributes Default Description
data Object | Array

輸入數據物件或陣列

option Object <optional>
{}

輸入設定物件,預設為{}

Properties
Name Type Attributes Default Description
instance Object <optional>
null

輸入實例instance物件,預設為null

transaction Object <optional>
null

輸入交易(transaction)物件,預設為null

Returns:

回傳Promise,resolve回傳刪除結果,reject回傳錯誤訊息

Type
Promise

(async, static) delAll(findopt, optionopt) → {Promise}

Description:
  • 刪除全部數據,需與del分開,避免未傳數據導致直接刪除全表

Source:
Parameters:
Name Type Attributes Default Description
find Object <optional>
{}

輸入刪除條件物件

option Object <optional>
{}

輸入設定物件,預設為{}

Properties
Name Type Attributes Default Description
instance Object <optional>
null

輸入實例instance物件,預設為null

transaction Object <optional>
null

輸入交易(transaction)物件,預設為null

Returns:

回傳Promise,resolve回傳刪除結果,reject回傳錯誤訊息

Type
Promise

(static) genModelsByTabs(fdopt, tabsopt, optopt)

Description:
  • 由資料表物件生成各資料表的models資料

Source:
Parameters:
Name Type Attributes Default Description
fd String <optional>
'./models'

輸入models儲存的資料夾名稱字串,預設'./models'

tabs Object <optional>
{}

輸入各資料表物件,預設{}

opt Object <optional>
{}

輸入設定物件,預設{}

Properties
Name Type Attributes Default Description
type String <optional>
'js'

輸入資料表類型字串,預設'js'

(async, static) initAdodb() → {Promise}

Description:
  • 初始化adodb

Source:
Returns:

回傳Promise,resolve代表關閉成功,reject回傳錯誤訊息

Type
Promise

(async, static) insert(data, optionopt) → {Promise}

Description:
  • 插入數據,插入同樣數據會自動產生不同_id,故insert前需自行判斷有無重複

Source:
Parameters:
Name Type Attributes Default Description
data Object | Array

輸入數據物件或陣列

option Object <optional>
{}

輸入設定物件,預設為{}

Properties
Name Type Attributes Default Description
instance Object <optional>
null

輸入實例instance物件,預設為null

transaction Object <optional>
null

輸入交易(transaction)物件,預設為null

Returns:

回傳Promise,resolve回傳插入結果,reject回傳錯誤訊息

Type
Promise

(async, static) save(data, optionopt) → {Promise}

Description:
  • 儲存數據

Source:
Parameters:
Name Type Attributes Default Description
data Object | Array

輸入數據物件或陣列

option Object <optional>
{}

輸入設定物件,預設為{}

Properties
Name Type Attributes Default Description
instance Object <optional>
null

輸入實例instance物件,預設為null

transaction Object <optional>
null

輸入交易(transaction)物件,預設為null

autoInsert boolean <optional>
true

輸入是否於儲存時發現原本無數據,則自動改以插入處理,預設為true

Returns:

回傳Promise,resolve回傳儲存結果,reject回傳錯誤訊息

Type
Promise

(async, static) select(findopt, optionopt) → {Promise}

Description:
  • 查詢數據

Source:
Parameters:
Name Type Attributes Default Description
find Object <optional>
{}

輸入查詢條件物件

option Object <optional>
{}

輸入設定物件,預設為{}

Properties
Name Type Attributes Default Description
instance Object <optional>
null

輸入實例instance物件,預設為null

transaction Object <optional>
null

輸入交易(transaction)物件,預設為null

Returns:

回傳Promise,resolve回傳數據,reject回傳錯誤訊息

Type
Promise