w-orm-lmdb 1.0.1

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.
Files changed (51) hide show
  1. package/.editorconfig +9 -0
  2. package/.eslintignore +3 -0
  3. package/.eslintrc.js +55 -0
  4. package/.jsdoc +25 -0
  5. package/LICENSE +21 -0
  6. package/README.md +187 -0
  7. package/SECURITY.md +5 -0
  8. package/babel.config.js +15 -0
  9. package/dist/w-orm-lmdb.umd.js +7 -0
  10. package/dist/w-orm-lmdb.umd.js.map +1 -0
  11. package/docs/WOrmLmdb.html +1406 -0
  12. package/docs/WOrmLmdb.mjs.html +633 -0
  13. package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  14. package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  15. package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  16. package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  17. package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  18. package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  19. package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  20. package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  21. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  22. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
  23. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  24. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  25. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  26. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  27. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
  28. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  29. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  30. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  31. package/docs/index.html +84 -0
  32. package/docs/scripts/collapse.js +39 -0
  33. package/docs/scripts/commonNav.js +28 -0
  34. package/docs/scripts/linenumber.js +25 -0
  35. package/docs/scripts/nav.js +12 -0
  36. package/docs/scripts/polyfill.js +4 -0
  37. package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
  38. package/docs/scripts/prettify/lang-css.js +2 -0
  39. package/docs/scripts/prettify/prettify.js +28 -0
  40. package/docs/scripts/search.js +99 -0
  41. package/docs/styles/jsdoc.css +776 -0
  42. package/docs/styles/prettify.css +80 -0
  43. package/g-basic.mjs +169 -0
  44. package/package.json +32 -0
  45. package/script.txt +18 -0
  46. package/src/WOrmLmdb.mjs +561 -0
  47. package/test/basic.test.mjs +395 -0
  48. package/toolg/addVersion.mjs +4 -0
  49. package/toolg/cleanFolder.mjs +4 -0
  50. package/toolg/gDistRollup.mjs +23 -0
  51. package/toolg/modifyReadme.mjs +4 -0
@@ -0,0 +1,80 @@
1
+ .pln {
2
+ color: #ddd;
3
+ }
4
+
5
+ /* string content */
6
+ .str {
7
+ color: #61ce3c;
8
+ }
9
+
10
+ /* a keyword */
11
+ .kwd {
12
+ color: #fbde2d;
13
+ }
14
+
15
+ /* a comment */
16
+ .com {
17
+ color: #aeaeae;
18
+ }
19
+
20
+ /* a type name */
21
+ .typ {
22
+ color: #8da6ce;
23
+ }
24
+
25
+ /* a literal value */
26
+ .lit {
27
+ color: #fbde2d;
28
+ }
29
+
30
+ /* punctuation */
31
+ .pun {
32
+ color: #ddd;
33
+ }
34
+
35
+ /* lisp open bracket */
36
+ .opn {
37
+ color: #000000;
38
+ }
39
+
40
+ /* lisp close bracket */
41
+ .clo {
42
+ color: #000000;
43
+ }
44
+
45
+ /* a markup tag name */
46
+ .tag {
47
+ color: #8da6ce;
48
+ }
49
+
50
+ /* a markup attribute name */
51
+ .atn {
52
+ color: #fbde2d;
53
+ }
54
+
55
+ /* a markup attribute value */
56
+ .atv {
57
+ color: #ddd;
58
+ }
59
+
60
+ /* a declaration */
61
+ .dec {
62
+ color: #EF5050;
63
+ }
64
+
65
+ /* a variable name */
66
+ .var {
67
+ color: #c82829;
68
+ }
69
+
70
+ /* a function name */
71
+ .fun {
72
+ color: #4271ae;
73
+ }
74
+
75
+ /* Specify class=linenums on a pre to get line numbering */
76
+ ol.linenums {
77
+ margin-top: 0;
78
+ margin-bottom: 0;
79
+ padding-bottom: 2px;
80
+ }
package/g-basic.mjs ADDED
@@ -0,0 +1,169 @@
1
+ import _ from 'lodash-es'
2
+ // import w from 'wsemi'
3
+ import WOrm from './src/WOrmLmdb.mjs'
4
+ //import WOrm from './dist/w-orm-lmdb.umd.js'
5
+
6
+
7
+ // w.fsDeleteFolder('./_db')
8
+
9
+ let opt = {
10
+ url: './_db',
11
+ db: 'worm',
12
+ cl: 'users',
13
+ }
14
+
15
+ let rs = [
16
+ {
17
+ id: 'id-peter',
18
+ name: 'peter',
19
+ value: 123,
20
+ },
21
+ {
22
+ id: 'id-rosemary',
23
+ name: 'rosemary',
24
+ value: 123.456,
25
+ },
26
+ {
27
+ id: '',
28
+ name: 'kettle',
29
+ value: 456,
30
+ },
31
+ ]
32
+
33
+ let rsm = [
34
+ {
35
+ id: 'id-peter',
36
+ name: 'peter(modify)'
37
+ },
38
+ {
39
+ id: 'id-rosemary',
40
+ name: 'rosemary(modify)'
41
+ },
42
+ {
43
+ id: '',
44
+ name: 'kettle(modify)'
45
+ },
46
+ ]
47
+
48
+ async function test() {
49
+
50
+ //wo
51
+ let wo = WOrm(opt)
52
+
53
+ //on
54
+ wo.on('change', function(mode, data, res) {
55
+ console.log('change', mode)
56
+ })
57
+
58
+ //delAll
59
+ await wo.delAll()
60
+ .then(function(msg) {
61
+ console.log('delAll then', msg)
62
+ })
63
+ .catch(function(msg) {
64
+ console.log('delAll catch', msg)
65
+ })
66
+
67
+ //insert
68
+ await wo.insert(rs)
69
+ .then(function(msg) {
70
+ console.log('insert then', msg)
71
+ })
72
+ .catch(function(msg) {
73
+ console.log('insert catch', msg)
74
+ })
75
+
76
+ //save
77
+ await wo.save(rsm, { autoInsert: false })
78
+ .then(function(msg) {
79
+ console.log('save then', msg)
80
+ })
81
+ .catch(function(msg) {
82
+ console.log('save catch', msg)
83
+ })
84
+
85
+ //select all
86
+ let ss = await wo.select()
87
+ ss = _.sortBy(ss, 'name')
88
+ console.log('select all', ss)
89
+
90
+ //select
91
+ let so = await wo.select({ id: 'id-rosemary' })
92
+ console.log('select', so)
93
+
94
+ //select by $and, $gt, $lt
95
+ let spa = await wo.select({ '$and': [{ value: { '$gt': 123 } }, { value: { '$lt': 200 } }] })
96
+ console.log('select by $and, $gt, $lt', spa)
97
+
98
+ //select by $or, $gte, $lte
99
+ let spb = await wo.select({ '$or': [{ value: { '$lte': -1 } }, { value: { '$gte': 200 } }] })
100
+ console.log('select by $or, $gte, $lte', spb)
101
+
102
+ //select by $or, $and, $ne, $in, $nin
103
+ let spc = await wo.select({ '$or': [{ '$and': [{ value: { '$ne': 123 } }, { value: { '$in': [123, 321, 123.456, 456] } }, { value: { '$nin': [456, 654] } }] }, { '$or': [{ value: { '$lte': -1 } }, { value: { '$gte': 400 } }] }] })
104
+ spc = _.sortBy(spc, 'name')
105
+ console.log('select by $or, $and, $ne, $in, $nin', spc)
106
+
107
+ // //select by regex //mingo不支援regex
108
+ // let sr = await wo.select({ name: { $regex: 'PeT', $options: '$i' } })
109
+ // console.log('selectReg', sr)
110
+
111
+ //del
112
+ let d = ss.filter(function(v) {
113
+ return v.name === 'kettle'
114
+ })
115
+ await wo.del(d)
116
+ .then(function(msg) {
117
+ console.log('del then', msg)
118
+ })
119
+ .catch(function(msg) {
120
+ console.log('del catch', msg)
121
+ })
122
+
123
+ }
124
+ test()
125
+ // change delAll
126
+ // delAll then { n: 2, nDeleted: 2, ok: 1 }
127
+ // change insert
128
+ // insert then { n: 3, nInserted: 3, ok: 1 }
129
+ // change save
130
+ // save then [
131
+ // { n: 1, nModified: 1, ok: 1 },
132
+ // { n: 1, nModified: 1, ok: 1 },
133
+ // { n: 0, nModified: 0, ok: 1 }
134
+ // ]
135
+ // select all [
136
+ // {
137
+ // id: {random id},
138
+ // name: 'kettle',
139
+ // value: 456
140
+ // },
141
+ // { id: 'id-peter', name: 'peter(modify)', value: 123 },
142
+ // { id: 'id-rosemary', name: 'rosemary(modify)', value: 123.456 }
143
+ // ]
144
+ // select [ { id: 'id-rosemary', name: 'rosemary(modify)', value: 123.456 } ]
145
+ // select by $and, $gt, $lt [ { id: 'id-rosemary', name: 'rosemary(modify)', value: 123.456 } ]
146
+ // select by $or, $gte, $lte [
147
+ // {
148
+ // id: {random id},
149
+ // name: 'kettle',
150
+ // value: 456
151
+ // }
152
+ // ]
153
+ // select by $or, $and, $ne, $in, $nin [
154
+ // {
155
+ // id: {random id},
156
+ // name: 'kettle',
157
+ // value: 456
158
+ // },
159
+ // {
160
+ // id: 'id-rosemary',
161
+ // name: 'rosemary(modify)',
162
+ // value: 123.456
163
+ // }
164
+ // ]
165
+ // change del
166
+ // del then [ { n: 1, nDeleted: 1, ok: 1 } ]
167
+
168
+
169
+ //node g-basic.mjs
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "w-orm-lmdb",
3
+ "version": "1.0.1",
4
+ "main": "dist/w-orm-lmdb.umd.js",
5
+ "dependencies": {
6
+ "lodash-es": "^4.17.21",
7
+ "lmdb": "^3.3.0",
8
+ "mingo": "^6.6.1",
9
+ "wsemi": "^1.7.90"
10
+ },
11
+ "devDependencies": {
12
+ "w-package-tools": "^1.0.90"
13
+ },
14
+ "scripts": {
15
+ "test": "mocha --parallel --timeout 60000",
16
+ "deploy": "gh-pages -d docs"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/yuda-lyu/w-orm-lmdb.git"
21
+ },
22
+ "keywords": [
23
+ "package",
24
+ "tool",
25
+ "operator",
26
+ "lmdb",
27
+ "ORM",
28
+ "nodejs"
29
+ ],
30
+ "author": "yuda-lyu(semisphere)",
31
+ "license": "MIT"
32
+ }
package/script.txt ADDED
@@ -0,0 +1,18 @@
1
+ #node toolg/addVersion.mjs
2
+ node toolg/modifyReadme.mjs
3
+
4
+ node toolg/cleanFolder.mjs
5
+ ./node_modules/.bin/jsdoc -c .jsdoc
6
+
7
+ node toolg/gDistRollup.mjs
8
+
9
+ git add . -A
10
+ git commit -m 'modify: '
11
+ git push origin master:master
12
+
13
+ npm run deploy
14
+
15
+ #npm test
16
+
17
+ #npm publish
18
+