new WOrmMongodb(optopt) → {Object}
- Description:
操作資料庫(MongoDB)
- Source:
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opt |
Object |
<optional> |
{}
|
輸入設定物件,預設{} Properties
|
Returns:
回傳操作資料庫物件,各事件功能詳見說明
- Type
- Object
Methods
(async, static) del(data) → {Promise}
- Description:
刪除數據
- Source:
Parameters:
Name | Type | Description |
---|---|---|
data |
Object | Array | 輸入數據物件或陣列 |
Returns:
回傳Promise,resolve回傳刪除結果,reject回傳錯誤訊息
- Type
- Promise
(async, static) delAll(findopt) → {Promise}
- Description:
刪除全部數據,需與del分開,避免未傳數據導致直接刪除全表
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
find |
Object |
<optional> |
{}
|
輸入刪除條件物件 |
Returns:
回傳Promise,resolve回傳刪除結果,reject回傳錯誤訊息
- Type
- Promise
(async, static) delAllGfs(findopt) → {Promise}
- Description:
使用GridFS,刪除全部數據,需與del分開,避免未傳數據導致直接刪除全表
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
find |
Object |
<optional> |
{}
|
輸入刪除條件物件 |
Returns:
回傳Promise,resolve回傳刪除結果,reject回傳錯誤訊息
- Type
- Promise
(async, static) delGfs(id) → {Promise}
- Description:
使用GridFS,刪除數據
- Source:
Parameters:
Name | Type | Description |
---|---|---|
id |
String | 輸入刪除id字串 |
Returns:
回傳Promise,resolve回傳刪除結果,reject回傳錯誤訊息
- Type
- Promise
(async, static) insert(data) → {Promise}
- Description:
插入數據,插入同樣數據會自動產生不同_id,故insert前需自行判斷有無重複
- Source:
Parameters:
Name | Type | Description |
---|---|---|
data |
Object | Array | 輸入數據物件或陣列 |
Returns:
回傳Promise,resolve回傳插入結果,reject回傳錯誤訊息
- Type
- Promise
(async, static) insertGfs(u8a) → {Promise}
- Description:
使用GridFS,插入數據,需為Uint8Array格式
- Source:
Parameters:
Name | Type | Description |
---|---|---|
u8a |
Uint8Array |
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
|
Returns:
回傳Promise,resolve回傳儲存結果,reject回傳錯誤訊息
- Type
- Promise
(async, static) select(findopt) → {Promise}
- Description:
查詢數據
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
find |
Object |
<optional> |
{}
|
輸入查詢條件物件 |
Returns:
回傳Promise,resolve回傳數據,reject回傳錯誤訊息
- Type
- Promise
(async, static) selectGfs(id) → {Promise}
- Description:
使用GridFS,查詢數據
- Source:
Parameters:
Name | Type | Description |
---|---|---|
id |
String | 輸入查詢id字串 |
Returns:
回傳Promise,resolve回傳數據,reject回傳錯誤訊息
- Type
- Promise