doix-db 1.0.60 → 1.0.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +2 -0
- package/lib/DbClient.js +6 -0
- package/lib/DbLang.js +6 -0
- package/lib/DbQueue.js +28 -0
- package/lib/model/DbView.js +5 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -7,6 +7,8 @@ module.exports = {
|
|
|
7
7
|
DbPool: require ('./lib/DbPool.js'),
|
|
8
8
|
DbLang: require ('./lib/DbLang.js'),
|
|
9
9
|
DbCsvPrinter: require ('./lib/DbCsvPrinter.js'),
|
|
10
|
+
DbQueue: require ('./lib/DbQueue.js'),
|
|
11
|
+
|
|
10
12
|
DbColumn: require ('./lib/model/DbColumn.js'),
|
|
11
13
|
DbReference: require ('./lib/model/DbReference.js'),
|
|
12
14
|
DbObjectMerger: require ('./lib/model/DbObjectMerger.js'),
|
package/lib/DbClient.js
CHANGED
package/lib/DbLang.js
CHANGED
package/lib/DbQueue.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const {Queue} = require ('doix')
|
|
2
|
+
|
|
3
|
+
class DbQueue extends Queue {
|
|
4
|
+
|
|
5
|
+
constructor (view, o) {
|
|
6
|
+
|
|
7
|
+
if (!('order' in o)) throw Error ('DbQueuePg: order not set for ' + view.name)
|
|
8
|
+
|
|
9
|
+
if ('maxPending' in o && o.maxPending !== 1) throw Error (`DbQueuePg: maxPending=${o.maxPending} set for ${view.name}, must be 1`)
|
|
10
|
+
|
|
11
|
+
super (view.model.db.app, o)
|
|
12
|
+
|
|
13
|
+
this.view = view
|
|
14
|
+
this.order = o.order
|
|
15
|
+
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async peek (job) {
|
|
19
|
+
|
|
20
|
+
const {view} = this
|
|
21
|
+
|
|
22
|
+
return job [view.model.db.name].peek (view)
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = DbQueue
|
package/lib/model/DbView.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const DbRelation = require ('./DbRelation.js')
|
|
2
|
+
const DbQueue = require ('../DbQueue.js')
|
|
2
3
|
|
|
3
4
|
class DbView extends DbRelation {
|
|
4
5
|
|
|
@@ -14,18 +15,18 @@ class DbView extends DbRelation {
|
|
|
14
15
|
|
|
15
16
|
if (typeof this.wrap !== 'boolean') throw Error (`${this.name}: wrap option must be boolean`)
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
}
|
|
18
|
+
}
|
|
19
19
|
|
|
20
20
|
setLang (lang) {
|
|
21
21
|
|
|
22
22
|
super.setLang (lang)
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
if (this.wrap) lang.wrapViewSql (this)
|
|
25
25
|
|
|
26
|
+
if (this.queue) this.queue = new DbQueue (this, this.queue)
|
|
27
|
+
|
|
26
28
|
}
|
|
27
29
|
|
|
28
|
-
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
module.exports = DbView
|