w-orm-reladb 1.0.32 → 1.0.36
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/.eslintrc.js +53 -49
- package/.github/workflows/ci-test.yml +2 -1
- package/README.md +40 -34
- package/SECURITY.md +5 -0
- package/dist/w-orm-reladb.umd.js +3 -3
- package/dist/w-orm-reladb.umd.js.map +1 -1
- package/docs/WOrmReladb.html +1 -1
- package/docs/WOrmReladb.mjs.html +5 -5
- package/docs/index.html +1 -1
- package/{sp-genModelsByTabs.mjs → g-genModelsByTabs.mjs} +1 -1
- package/{sp-mssql-concurrency.mjs → g-mssql-concurrency.mjs} +1 -1
- package/{sp-mssql-timerQuery.mjs → g-mssql-timerQuery.mjs} +1 -1
- package/{sp-mssql-transaction-commit.mjs → g-mssql-transaction-commit.mjs} +4 -3
- package/{sp-mssql-transaction-rollback.mjs → g-mssql-transaction-rollback.mjs} +5 -4
- package/{sp-mssql.mjs → g-mssql.mjs} +6 -5
- package/{sp-sqlite-concurrency.mjs → g-sqlite-concurrency.mjs} +2 -2
- package/g-sqlite-encryption-transaction-commit.mjs +196 -0
- package/{sp-sqlite-encryption-transaction-rollback.mjs → g-sqlite-encryption-transaction-rollback.mjs} +1 -1
- package/{sp-sqlite-encryption.mjs → g-sqlite-encryption.mjs} +6 -5
- package/{sp-sqlite-transaction-commit.mjs → g-sqlite-transaction-commit.mjs} +6 -5
- package/{sp-sqlite-transaction-rollback.mjs → g-sqlite-transaction-rollback.mjs} +6 -5
- package/{sp-sqlite.mjs → g-sqlite.mjs} +6 -5
- package/package.json +11 -11
- package/src/WOrmReladb.mjs +4 -4
- package/test/{all.test.js → all.test.mjs} +0 -0
- package/worm.sqlite +0 -0
- package/sp-sqlite-encryption-transaction-commit.mjs +0 -195
package/docs/WOrmReladb.html
CHANGED
|
@@ -3724,7 +3724,7 @@
|
|
|
3724
3724
|
<br class="clear">
|
|
3725
3725
|
|
|
3726
3726
|
<footer>
|
|
3727
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.
|
|
3727
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.7</a> on Thu Dec 16 2021 14:06:07 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
3728
3728
|
</footer>
|
|
3729
3729
|
|
|
3730
3730
|
<script>prettyPrint();</script>
|
package/docs/WOrmReladb.mjs.html
CHANGED
|
@@ -57,7 +57,7 @@ import isarr from 'wsemi/src/isarr.mjs'
|
|
|
57
57
|
import isobj from 'wsemi/src/isobj.mjs'
|
|
58
58
|
import isbol from 'wsemi/src/isbol.mjs'
|
|
59
59
|
import isestr from 'wsemi/src/isestr.mjs'
|
|
60
|
-
import
|
|
60
|
+
import arrHas from 'wsemi/src/arrHas.mjs'
|
|
61
61
|
import pmSeries from 'wsemi/src/pmSeries.mjs'
|
|
62
62
|
import pm2resolve from 'wsemi/src/pm2resolve.mjs'
|
|
63
63
|
import pmQueue from 'wsemi/src/pmQueue.mjs'
|
|
@@ -147,7 +147,7 @@ function WOrmReladb(opt = {}) {
|
|
|
147
147
|
console.log('no dialect in opt.url')
|
|
148
148
|
return ee
|
|
149
149
|
}
|
|
150
|
-
if (!
|
|
150
|
+
if (!arrHas(dialect, ['mssql', 'sqlite', 'mysql', 'mariadb', 'postgres'])) {
|
|
151
151
|
console.log('invalid dialect in opt.url')
|
|
152
152
|
return ee
|
|
153
153
|
}
|
|
@@ -507,7 +507,7 @@ function WOrmReladb(opt = {}) {
|
|
|
507
507
|
//bulkCreate
|
|
508
508
|
await md.bulkCreate(data, setting)
|
|
509
509
|
.then((res) => {
|
|
510
|
-
res = { n, ok: 1 }
|
|
510
|
+
res = { n, nInserted: n, ok: 1 }
|
|
511
511
|
pm.resolve(res)
|
|
512
512
|
ee.emit('change', 'insert', data, res)
|
|
513
513
|
})
|
|
@@ -927,7 +927,7 @@ function WOrmReladb(opt = {}) {
|
|
|
927
927
|
//destroy
|
|
928
928
|
await md.destroy(setting)
|
|
929
929
|
.then((res) => {
|
|
930
|
-
res = { n: res, ok: 1 }
|
|
930
|
+
res = { n: res, nDeleted: res, ok: 1 }
|
|
931
931
|
pm.resolve(res)
|
|
932
932
|
ee.emit('change', 'delAll', null, res)
|
|
933
933
|
})
|
|
@@ -1108,7 +1108,7 @@ export default WOrmReladb
|
|
|
1108
1108
|
<br class="clear">
|
|
1109
1109
|
|
|
1110
1110
|
<footer>
|
|
1111
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.
|
|
1111
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.7</a> on Thu Dec 16 2021 14:06:07 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
1112
1112
|
</footer>
|
|
1113
1113
|
|
|
1114
1114
|
<script>prettyPrint();</script>
|
package/docs/index.html
CHANGED
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
<br class="clear">
|
|
69
69
|
|
|
70
70
|
<footer>
|
|
71
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.
|
|
71
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.7</a> on Thu Dec 16 2021 14:06:07 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
72
72
|
</footer>
|
|
73
73
|
|
|
74
74
|
<script>prettyPrint();</script>
|
|
@@ -70,4 +70,4 @@ test()
|
|
|
70
70
|
// generate file: ./models/tb2.json
|
|
71
71
|
// generate file: ./models/tb3.json
|
|
72
72
|
|
|
73
|
-
//node --experimental-modules --es-module-specifier-resolution=node
|
|
73
|
+
//node --experimental-modules --es-module-specifier-resolution=node g-genModelsByTabs.mjs
|
|
@@ -106,4 +106,4 @@ test()
|
|
|
106
106
|
// save then 3 msg= [ { n: 1, nInserted: 1, ok: 1 } ]
|
|
107
107
|
// select then 4 len= 2
|
|
108
108
|
|
|
109
|
-
//node --experimental-modules --es-module-specifier-resolution=node
|
|
109
|
+
//node --experimental-modules --es-module-specifier-resolution=node g-mssql-concurrency.mjs
|
|
@@ -197,12 +197,13 @@ testCommit()
|
|
|
197
197
|
// delAll then { n: 2, ok: 1 }
|
|
198
198
|
// init
|
|
199
199
|
// change insert
|
|
200
|
-
// insert then { n: 3, ok: 1 }
|
|
200
|
+
// insert then { n: 3, nInserted: 3, ok: 1 }
|
|
201
201
|
// change save
|
|
202
202
|
// save then [
|
|
203
203
|
// { n: 1, nModified: 1, ok: 1 },
|
|
204
204
|
// { n: 1, nModified: 1, ok: 1 },
|
|
205
|
-
// { n: 0, nModified: 0, ok: 1 }
|
|
205
|
+
// { n: 0, nModified: 0, ok: 1 } //autoInsert=false
|
|
206
|
+
// { n: 1, nInserted: 1, ok: 1 } //autoInsert=true
|
|
206
207
|
// ]
|
|
207
208
|
// change del
|
|
208
209
|
// del then [
|
|
@@ -220,4 +221,4 @@ testCommit()
|
|
|
220
221
|
// ]
|
|
221
222
|
// commit success
|
|
222
223
|
|
|
223
|
-
//node --experimental-modules --es-module-specifier-resolution=node
|
|
224
|
+
//node --experimental-modules --es-module-specifier-resolution=node g-mssql-transaction-commit.mjs
|
|
@@ -191,15 +191,16 @@ async function testRollback() {
|
|
|
191
191
|
testRollback()
|
|
192
192
|
// createStorage
|
|
193
193
|
// change delAll
|
|
194
|
-
// delAll then { n: 0, ok: 1 }
|
|
194
|
+
// delAll then { n: 0, nDeleted: 0, ok: 1 }
|
|
195
195
|
// init
|
|
196
196
|
// change insert
|
|
197
|
-
// insert then { n: 3, ok: 1 }
|
|
197
|
+
// insert then { n: 3, nInserted: 3, ok: 1 }
|
|
198
198
|
// change save
|
|
199
199
|
// save then [
|
|
200
200
|
// { n: 1, nModified: 1, ok: 1 },
|
|
201
201
|
// { n: 1, nModified: 1, ok: 1 },
|
|
202
|
-
// { n: 0, nModified: 0, ok: 1 }
|
|
202
|
+
// { n: 0, nModified: 0, ok: 1 } //autoInsert=false
|
|
203
|
+
// { n: 1, nInserted: 1, ok: 1 } //autoInsert=true
|
|
203
204
|
// ]
|
|
204
205
|
// change del
|
|
205
206
|
// del then [
|
|
@@ -214,4 +215,4 @@ testRollback()
|
|
|
214
215
|
// select all (final) []
|
|
215
216
|
// rollback success
|
|
216
217
|
|
|
217
|
-
//node --experimental-modules --es-module-specifier-resolution=node
|
|
218
|
+
//node --experimental-modules --es-module-specifier-resolution=node g-mssql-transaction-rollback.mjs
|
|
@@ -99,7 +99,7 @@ async function test() {
|
|
|
99
99
|
|
|
100
100
|
|
|
101
101
|
//save
|
|
102
|
-
await w.save(rsm, { autoInsert:
|
|
102
|
+
await w.save(rsm, { autoInsert: true })
|
|
103
103
|
.then(function(msg) {
|
|
104
104
|
console.log('save then', msg)
|
|
105
105
|
})
|
|
@@ -158,14 +158,15 @@ async function test() {
|
|
|
158
158
|
test()
|
|
159
159
|
// createStorage
|
|
160
160
|
// change delAll
|
|
161
|
-
// delAll then { n: 0, ok: 1 }
|
|
161
|
+
// delAll then { n: 0, nDeleted: 0, ok: 1 }
|
|
162
162
|
// change insert
|
|
163
|
-
// insert then { n: 3, ok: 1 }
|
|
163
|
+
// insert then { n: 3, nInserted: 3, ok: 1 }
|
|
164
164
|
// change save
|
|
165
165
|
// save then [
|
|
166
166
|
// { n: 1, nModified: 1, ok: 1 },
|
|
167
167
|
// { n: 1, nModified: 1, ok: 1 },
|
|
168
|
-
// { n: 0, nModified: 0, ok: 1 }
|
|
168
|
+
// { n: 0, nModified: 0, ok: 1 } //autoInsert=false
|
|
169
|
+
// { n: 1, nInserted: 1, ok: 1 } //autoInsert=true
|
|
169
170
|
// ]
|
|
170
171
|
// select all [
|
|
171
172
|
// { id: 'id-peter', name: 'peter(modify)', value: 123 },
|
|
@@ -194,4 +195,4 @@ test()
|
|
|
194
195
|
// { n: 1, nDeleted: 1, ok: 1 }
|
|
195
196
|
// ]
|
|
196
197
|
|
|
197
|
-
//node --experimental-modules --es-module-specifier-resolution=node
|
|
198
|
+
//node --experimental-modules --es-module-specifier-resolution=node g-mssql.mjs
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import wo from './src/WOrmReladb.mjs'
|
|
2
1
|
import fs from 'fs'
|
|
2
|
+
import wo from './src/WOrmReladb.mjs'
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
let username = ''
|
|
@@ -106,4 +106,4 @@ test()
|
|
|
106
106
|
// save then 3 msg= [ { n: 1, nInserted: 1, ok: 1 } ]
|
|
107
107
|
// select then 4 len= 2
|
|
108
108
|
|
|
109
|
-
//node --experimental-modules --es-module-specifier-resolution=node
|
|
109
|
+
//node --experimental-modules --es-module-specifier-resolution=node g-sqlite-concurrency.mjs
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
// import fs from 'fs'
|
|
2
|
+
// import wo from './src/WOrmReladb.mjs'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
// let username = 'username'
|
|
6
|
+
// let password = 'password'
|
|
7
|
+
// let opt = {
|
|
8
|
+
// url: `sqlite://${username}:${password}`,
|
|
9
|
+
// db: 'worm',
|
|
10
|
+
// cl: 'users',
|
|
11
|
+
// fdModels: './models',
|
|
12
|
+
// // modelType: 'json',
|
|
13
|
+
// // autoGenPK: false,
|
|
14
|
+
// storage: './worm.sqlite',
|
|
15
|
+
// useEncryption: true,
|
|
16
|
+
// }
|
|
17
|
+
|
|
18
|
+
// //因worm.sqlite可能為加密數據, 若有切換useEncryption時得先刪除, 再通過createStorage重新產生
|
|
19
|
+
// if (fs.existsSync(opt.storage)) {
|
|
20
|
+
// fs.unlinkSync(opt.storage)
|
|
21
|
+
// }
|
|
22
|
+
|
|
23
|
+
// let rs = [
|
|
24
|
+
// {
|
|
25
|
+
// id: 'id-peter',
|
|
26
|
+
// name: 'peter',
|
|
27
|
+
// value: 123,
|
|
28
|
+
// },
|
|
29
|
+
// {
|
|
30
|
+
// id: 'id-rosemary',
|
|
31
|
+
// name: 'rosemary',
|
|
32
|
+
// value: 123.456,
|
|
33
|
+
// },
|
|
34
|
+
// {
|
|
35
|
+
// id: '',
|
|
36
|
+
// name: 'kettle',
|
|
37
|
+
// value: 456,
|
|
38
|
+
// },
|
|
39
|
+
// ]
|
|
40
|
+
|
|
41
|
+
// let rsm = [
|
|
42
|
+
// {
|
|
43
|
+
// id: 'id-peter',
|
|
44
|
+
// name: 'peter(modify)'
|
|
45
|
+
// },
|
|
46
|
+
// {
|
|
47
|
+
// id: 'id-rosemary',
|
|
48
|
+
// name: 'rosemary(modify)'
|
|
49
|
+
// },
|
|
50
|
+
// {
|
|
51
|
+
// id: '',
|
|
52
|
+
// name: 'kettle(modify)'
|
|
53
|
+
// },
|
|
54
|
+
// ]
|
|
55
|
+
|
|
56
|
+
// async function testCommit() {
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
// //w
|
|
60
|
+
// let w = wo(opt)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
// //createStorage, create table for mssql
|
|
64
|
+
// await w.createStorage()
|
|
65
|
+
// console.log('createStorage')
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
// //genModelsByDB, disable if got models
|
|
69
|
+
// // await w.genModelsByDB({
|
|
70
|
+
// // username,
|
|
71
|
+
// // password,
|
|
72
|
+
// // dialect: 'mssql', //default
|
|
73
|
+
// // host: 'localhost', //default
|
|
74
|
+
// // port: 1433, //default
|
|
75
|
+
// // db: opt.db,
|
|
76
|
+
// // fdModels: opt.fdModels,
|
|
77
|
+
// // })
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
// //on
|
|
81
|
+
// w.on('change', function(mode, data, res) {
|
|
82
|
+
// console.log('change', mode)
|
|
83
|
+
// })
|
|
84
|
+
// w.on('error', function(err) {
|
|
85
|
+
// console.log('error', err)
|
|
86
|
+
// })
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
// //delAll
|
|
90
|
+
// await w.delAll()
|
|
91
|
+
// .then(function(msg) {
|
|
92
|
+
// console.log('delAll then', msg)
|
|
93
|
+
// })
|
|
94
|
+
// .catch(function(msg) {
|
|
95
|
+
// console.log('delAll catch', msg)
|
|
96
|
+
// })
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
// //connState
|
|
100
|
+
// let instance = await w.init()
|
|
101
|
+
// let transaction = await w.genTransaction()
|
|
102
|
+
// let connState = {
|
|
103
|
+
// instance, //可由外部初始化共用instance, 可單獨使用不另外給transaction
|
|
104
|
+
// transaction, //若外部使用共用之transaction, 亦需使用共用instance
|
|
105
|
+
// }
|
|
106
|
+
// console.log('init')
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
// //insert
|
|
110
|
+
// await w.insert(rs, connState)
|
|
111
|
+
// .then(function(msg) {
|
|
112
|
+
// console.log('insert then', msg)
|
|
113
|
+
// })
|
|
114
|
+
// .catch(function(msg) {
|
|
115
|
+
// console.log('insert catch', msg)
|
|
116
|
+
// })
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
// //save
|
|
120
|
+
// await w.save(rsm, { ...connState, autoInsert: false })
|
|
121
|
+
// .then(function(msg) {
|
|
122
|
+
// console.log('save then', msg)
|
|
123
|
+
// })
|
|
124
|
+
// .catch(function(msg) {
|
|
125
|
+
// console.log('save catch', msg)
|
|
126
|
+
// })
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
// //del
|
|
130
|
+
// await w.del({ id: 'id-rosemary' }, connState)
|
|
131
|
+
// .then(function(msg) {
|
|
132
|
+
// console.log('del then', msg)
|
|
133
|
+
// })
|
|
134
|
+
// .catch(function(msg) {
|
|
135
|
+
// console.log('del catch', msg)
|
|
136
|
+
// })
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
// //select all
|
|
140
|
+
// let ssBeforeCommit = await w.select(null, connState)
|
|
141
|
+
// console.log('select all (before commit)', ssBeforeCommit) //此時select可查到暫時有效的數據
|
|
142
|
+
// // => [
|
|
143
|
+
// // { id: 'id-peter', name: 'peter(modify)', value: 123 },
|
|
144
|
+
// // { id: '{random id}', name: 'kettle', value: 456 }
|
|
145
|
+
// // ]
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
// //commit
|
|
149
|
+
// await transaction.commit()
|
|
150
|
+
// console.log('commit')
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
// //close
|
|
154
|
+
// await instance.close()
|
|
155
|
+
// console.log('close')
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
// //select all
|
|
159
|
+
// let ssFinal = await w.select()
|
|
160
|
+
// console.log('select all (final)', ssFinal)
|
|
161
|
+
// // => [
|
|
162
|
+
// // { id: 'id-peter', name: 'peter(modify)', value: 123 },
|
|
163
|
+
// // { id: '{random id}', name: 'kettle', value: 456 }
|
|
164
|
+
// // ]
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
// //check
|
|
168
|
+
// let rPeter = ssFinal.filter((v) => {
|
|
169
|
+
// return v.name === 'peter(modify)'
|
|
170
|
+
// })
|
|
171
|
+
// let bPeter = rPeter?.[0]?.value === 123
|
|
172
|
+
|
|
173
|
+
// let rRosemary = ssFinal.filter((v) => {
|
|
174
|
+
// return v.name === 'rosemary(modify)'
|
|
175
|
+
// })
|
|
176
|
+
// let bRosemary = rRosemary?.[0]?.value === 123.456
|
|
177
|
+
|
|
178
|
+
// let rKettle = ssFinal.filter((v) => {
|
|
179
|
+
// return v.name === 'kettle'
|
|
180
|
+
// })
|
|
181
|
+
// let bKettle = rKettle?.[0]?.value === 456
|
|
182
|
+
|
|
183
|
+
// if (bPeter && !bRosemary && bKettle) {
|
|
184
|
+
// console.log('commit success')
|
|
185
|
+
// }
|
|
186
|
+
// else {
|
|
187
|
+
// console.log('commit error')
|
|
188
|
+
// }
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
// }
|
|
192
|
+
// testCommit()
|
|
193
|
+
|
|
194
|
+
// @journeyapps/sqlcipher can not support transaction.
|
|
195
|
+
|
|
196
|
+
//node --experimental-modules --es-module-specifier-resolution=node g-sqlite-encryption-transaction-commit.mjs
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @journeyapps/sqlcipher can not support transaction.
|
|
2
2
|
|
|
3
|
-
//node --experimental-modules --es-module-specifier-resolution=node
|
|
3
|
+
//node --experimental-modules --es-module-specifier-resolution=node g-sqlite-encryption-transaction-rollback.mjs
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import wo from './src/WOrmReladb.mjs'
|
|
2
1
|
import fs from 'fs'
|
|
2
|
+
import wo from './src/WOrmReladb.mjs'
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
let username = 'username'
|
|
@@ -173,14 +173,15 @@ async function test() {
|
|
|
173
173
|
test()
|
|
174
174
|
// createStorage
|
|
175
175
|
// change delAll
|
|
176
|
-
// delAll then { n: 0, ok: 1 }
|
|
176
|
+
// delAll then { n: 0, nDeleted: 0, ok: 1 }
|
|
177
177
|
// change insert
|
|
178
|
-
// insert then { n: 3, ok: 1 }
|
|
178
|
+
// insert then { n: 3, nInserted: 3, ok: 1 }
|
|
179
179
|
// change save
|
|
180
180
|
// save then [
|
|
181
181
|
// { n: 1, nModified: 1, ok: 1 },
|
|
182
182
|
// { n: 1, nModified: 1, ok: 1 },
|
|
183
|
-
// { n: 0, nModified: 0, ok: 1 }
|
|
183
|
+
// { n: 0, nModified: 0, ok: 1 } //autoInsert=false
|
|
184
|
+
// { n: 1, nInserted: 1, ok: 1 } //autoInsert=true
|
|
184
185
|
// ]
|
|
185
186
|
// select all [
|
|
186
187
|
// { id: 'id-peter', name: 'peter(modify)', value: 123 },
|
|
@@ -209,4 +210,4 @@ test()
|
|
|
209
210
|
// { n: 1, nDeleted: 1, ok: 1 }
|
|
210
211
|
// ]
|
|
211
212
|
|
|
212
|
-
//node --experimental-modules --es-module-specifier-resolution=node
|
|
213
|
+
//node --experimental-modules --es-module-specifier-resolution=node g-sqlite-encryption.mjs
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import wo from './src/WOrmReladb.mjs'
|
|
2
1
|
import fs from 'fs'
|
|
2
|
+
import wo from './src/WOrmReladb.mjs'
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
let username = ''
|
|
@@ -201,15 +201,16 @@ async function testCommit() {
|
|
|
201
201
|
testCommit()
|
|
202
202
|
// createStorage
|
|
203
203
|
// change delAll
|
|
204
|
-
// delAll then { n: 0, ok: 1 }
|
|
204
|
+
// delAll then { n: 0, nDeleted: 0, ok: 1 }
|
|
205
205
|
// init
|
|
206
206
|
// change insert
|
|
207
|
-
// insert then { n: 3, ok: 1 }
|
|
207
|
+
// insert then { n: 3, nInserted: 3, ok: 1 }
|
|
208
208
|
// change save
|
|
209
209
|
// save then [
|
|
210
210
|
// { n: 1, nModified: 1, ok: 1 },
|
|
211
211
|
// { n: 1, nModified: 1, ok: 1 },
|
|
212
|
-
// { n: 0, nModified: 0, ok: 1 }
|
|
212
|
+
// { n: 0, nModified: 0, ok: 1 } //autoInsert=false
|
|
213
|
+
// { n: 1, nInserted: 1, ok: 1 } //autoInsert=true
|
|
213
214
|
// ]
|
|
214
215
|
// change del
|
|
215
216
|
// del then [
|
|
@@ -227,4 +228,4 @@ testCommit()
|
|
|
227
228
|
// ]
|
|
228
229
|
// commit success
|
|
229
230
|
|
|
230
|
-
//node --experimental-modules --es-module-specifier-resolution=node
|
|
231
|
+
//node --experimental-modules --es-module-specifier-resolution=node g-sqlite-transaction-commit.mjs
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import wo from './src/WOrmReladb.mjs'
|
|
2
1
|
import fs from 'fs'
|
|
2
|
+
import wo from './src/WOrmReladb.mjs'
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
let username = ''
|
|
@@ -198,15 +198,16 @@ async function testRollback() {
|
|
|
198
198
|
testRollback()
|
|
199
199
|
// createStorage
|
|
200
200
|
// change delAll
|
|
201
|
-
// delAll then { n: 0, ok: 1 }
|
|
201
|
+
// delAll then { n: 0, nDeleted: 0, ok: 1 }
|
|
202
202
|
// init
|
|
203
203
|
// change insert
|
|
204
|
-
// insert then { n: 3, ok: 1 }
|
|
204
|
+
// insert then { n: 3, nInserted: 3, ok: 1 }
|
|
205
205
|
// change save
|
|
206
206
|
// save then [
|
|
207
207
|
// { n: 1, nModified: 1, ok: 1 },
|
|
208
208
|
// { n: 1, nModified: 1, ok: 1 },
|
|
209
|
-
// { n: 0, nModified: 0, ok: 1 }
|
|
209
|
+
// { n: 0, nModified: 0, ok: 1 } //autoInsert=false
|
|
210
|
+
// { n: 1, nInserted: 1, ok: 1 } //autoInsert=true
|
|
210
211
|
// ]
|
|
211
212
|
// change del
|
|
212
213
|
// del then [
|
|
@@ -221,4 +222,4 @@ testRollback()
|
|
|
221
222
|
// select all (final) []
|
|
222
223
|
// rollback success
|
|
223
224
|
|
|
224
|
-
//node --experimental-modules --es-module-specifier-resolution=node
|
|
225
|
+
//node --experimental-modules --es-module-specifier-resolution=node g-sqlite-transaction-rollback.mjs
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import wo from './src/WOrmReladb.mjs'
|
|
2
1
|
import fs from 'fs'
|
|
2
|
+
import wo from './src/WOrmReladb.mjs'
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
let username = ''
|
|
@@ -166,14 +166,15 @@ async function test() {
|
|
|
166
166
|
test()
|
|
167
167
|
// createStorage
|
|
168
168
|
// change delAll
|
|
169
|
-
// delAll then { n: 0, ok: 1 }
|
|
169
|
+
// delAll then { n: 0, nDeleted: 0, ok: 1 }
|
|
170
170
|
// change insert
|
|
171
|
-
// insert then { n: 3, ok: 1 }
|
|
171
|
+
// insert then { n: 3, nInserted: 3, ok: 1 }
|
|
172
172
|
// change save
|
|
173
173
|
// save then [
|
|
174
174
|
// { n: 1, nModified: 1, ok: 1 },
|
|
175
175
|
// { n: 1, nModified: 1, ok: 1 },
|
|
176
|
-
// { n: 0, nModified: 0, ok: 1 }
|
|
176
|
+
// { n: 0, nModified: 0, ok: 1 } //autoInsert=false
|
|
177
|
+
// { n: 1, nInserted: 1, ok: 1 } //autoInsert=true
|
|
177
178
|
// ]
|
|
178
179
|
// select all [
|
|
179
180
|
// { id: 'id-peter', name: 'peter(modify)', value: 123 },
|
|
@@ -202,4 +203,4 @@ test()
|
|
|
202
203
|
// { n: 1, nDeleted: 1, ok: 1 }
|
|
203
204
|
// ]
|
|
204
205
|
|
|
205
|
-
//node --experimental-modules --es-module-specifier-resolution=node
|
|
206
|
+
//node --experimental-modules --es-module-specifier-resolution=node g-sqlite.mjs
|
package/package.json
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "w-orm-reladb",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "An object of operator for relational database in nodejs
|
|
3
|
+
"version": "1.0.36",
|
|
4
|
+
"description": "An object of operator for relational database in nodejs.",
|
|
5
5
|
"main": "dist/w-orm-reladb.umd.js",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"json5": "^2.
|
|
8
|
-
"lodash": "^4.17.
|
|
9
|
-
"mssql": "^
|
|
10
|
-
"sqlite3": "^5.0.
|
|
11
|
-
"w-auto-sequelize": "^1.0.
|
|
12
|
-
"wsemi": "^1.
|
|
7
|
+
"json5": "^2.2.0",
|
|
8
|
+
"lodash": "^4.17.21",
|
|
9
|
+
"mssql": "^7.3.0",
|
|
10
|
+
"sqlite3": "^5.0.2",
|
|
11
|
+
"w-auto-sequelize": "^1.0.17",
|
|
12
|
+
"wsemi": "^1.6.34"
|
|
13
13
|
},
|
|
14
14
|
"dependenciesTemp": {
|
|
15
15
|
"msg": "install sqlcipher for protection when db=sqlite",
|
|
16
|
-
"@journeyapps/sqlcipher": "^5.
|
|
16
|
+
"@journeyapps/sqlcipher": "^5.2.0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"w-package-tools": "^1.0.
|
|
19
|
+
"w-package-tools": "^1.0.59"
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
|
-
"test": "
|
|
22
|
+
"test": "mocha --parallel --timeout 60000 --experimental-modules --es-module-specifier-resolution=node",
|
|
23
23
|
"deploy": "gh-pages -d docs"
|
|
24
24
|
},
|
|
25
25
|
"repository": {
|
package/src/WOrmReladb.mjs
CHANGED
|
@@ -13,7 +13,7 @@ import isarr from 'wsemi/src/isarr.mjs'
|
|
|
13
13
|
import isobj from 'wsemi/src/isobj.mjs'
|
|
14
14
|
import isbol from 'wsemi/src/isbol.mjs'
|
|
15
15
|
import isestr from 'wsemi/src/isestr.mjs'
|
|
16
|
-
import
|
|
16
|
+
import arrHas from 'wsemi/src/arrHas.mjs'
|
|
17
17
|
import pmSeries from 'wsemi/src/pmSeries.mjs'
|
|
18
18
|
import pm2resolve from 'wsemi/src/pm2resolve.mjs'
|
|
19
19
|
import pmQueue from 'wsemi/src/pmQueue.mjs'
|
|
@@ -103,7 +103,7 @@ function WOrmReladb(opt = {}) {
|
|
|
103
103
|
console.log('no dialect in opt.url')
|
|
104
104
|
return ee
|
|
105
105
|
}
|
|
106
|
-
if (!
|
|
106
|
+
if (!arrHas(dialect, ['mssql', 'sqlite', 'mysql', 'mariadb', 'postgres'])) {
|
|
107
107
|
console.log('invalid dialect in opt.url')
|
|
108
108
|
return ee
|
|
109
109
|
}
|
|
@@ -463,7 +463,7 @@ function WOrmReladb(opt = {}) {
|
|
|
463
463
|
//bulkCreate
|
|
464
464
|
await md.bulkCreate(data, setting)
|
|
465
465
|
.then((res) => {
|
|
466
|
-
res = { n, ok: 1 }
|
|
466
|
+
res = { n, nInserted: n, ok: 1 }
|
|
467
467
|
pm.resolve(res)
|
|
468
468
|
ee.emit('change', 'insert', data, res)
|
|
469
469
|
})
|
|
@@ -883,7 +883,7 @@ function WOrmReladb(opt = {}) {
|
|
|
883
883
|
//destroy
|
|
884
884
|
await md.destroy(setting)
|
|
885
885
|
.then((res) => {
|
|
886
|
-
res = { n: res, ok: 1 }
|
|
886
|
+
res = { n: res, nDeleted: res, ok: 1 }
|
|
887
887
|
pm.resolve(res)
|
|
888
888
|
ee.emit('change', 'delAll', null, res)
|
|
889
889
|
})
|
|
File without changes
|
package/worm.sqlite
CHANGED
|
Binary file
|