neopg 2.0.4 → 2.0.6
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/lib/ModelChain.js +9 -0
- package/lib/NeoPG.js +4 -0
- package/package.json +1 -1
- package/test/test-db.js +1 -0
package/lib/ModelChain.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const makeId = require('./makeId.js')
|
|
4
4
|
const makeTimestamp = require('./makeTimestamp.js')
|
|
5
|
+
const serialId = makeId.serialId
|
|
5
6
|
|
|
6
7
|
// 提取常量定义
|
|
7
8
|
const INT_TYPES = new Set([
|
|
@@ -429,6 +430,10 @@ class ModelChain {
|
|
|
429
430
|
return this.ctx.transaction(callback)
|
|
430
431
|
}
|
|
431
432
|
|
|
433
|
+
model(name) {
|
|
434
|
+
return this.ctx.model(name)
|
|
435
|
+
}
|
|
436
|
+
|
|
432
437
|
async _aggregate(func, field) {
|
|
433
438
|
this._ensureActive()
|
|
434
439
|
try {
|
|
@@ -547,6 +552,10 @@ class ModelChain {
|
|
|
547
552
|
this.def.validateField(key, row[key])
|
|
548
553
|
}
|
|
549
554
|
}
|
|
555
|
+
|
|
556
|
+
makeId(len=16) {
|
|
557
|
+
return this.def ? this.def.makeId(this.def.pkLen) : serialId(len)
|
|
558
|
+
}
|
|
550
559
|
}
|
|
551
560
|
|
|
552
561
|
module.exports = ModelChain
|
package/lib/NeoPG.js
CHANGED
package/package.json
CHANGED