molly-db 1.0.20 → 1.0.22

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -1,199 +0,0 @@
1
- # LWDB : lightweight Database
2
-
3
- lw-db is a free and open source library for nodejs that allow you create a lightweight encrypted database using Json files
4
-
5
- # Usage
6
-
7
- ### init lwdb on nodeJS
8
- ```
9
-
10
- const lwdb = require('lwdb');
11
-
12
- ldb = new lwdb.createLocalDB( '/PATH/TO/DATA/BASE' ); // for non encrypted data
13
-
14
- // or
15
-
16
- ldb = new lwdb.createLocalDB( '/PATH/TO/DATA/BASE', 'PASSWORD' ); // for encrypted data
17
-
18
- ```
19
-
20
- ### init lwdb on Browser
21
- ```
22
-
23
- <script type="text/javascript" src="https://molly-js.github.io/MollyJS-Libs/molly.js" ></script>
24
-
25
- <script type="text/javascript">
26
- require( libs.crypto, libs.lwdb )
27
- .then( ()=>{
28
- ldb = new lwdb.createWebDB( 'PASSWORD' );
29
- } )
30
- </script>
31
-
32
- ```
33
-
34
- ### get an item list from a table
35
- ```
36
- let table = 'tableName' //NOTE: if table doesn't exist lwdb generates a new one
37
-
38
- let config = { offset:0, length:10 }
39
-
40
- ldb.list( table,config )
41
- .then( (response)=>{
42
- console.log( response );
43
- })
44
- ```
45
-
46
- ### fing from a target object
47
- ```
48
- let table = 'test';
49
-
50
- let target = {
51
- name:'Peter'
52
- }
53
-
54
- let logic = 'AND' or 'OR'
55
-
56
- let config = { // optional
57
- offset:0, length:10
58
- }
59
-
60
- ldb.find( table,target,logic,config )
61
- .then( (response)=>{
62
- console.log( response );
63
- });
64
-
65
- ```
66
-
67
- ### find by matching
68
- ```
69
- let table = 'test';
70
-
71
- let match = 'peter'
72
-
73
- let config = { // optional
74
- offset:0, length:10
75
- }
76
-
77
- ldb.match( table,match,config )
78
- .then( (response)=>{
79
- console.log( response );
80
- });
81
-
82
- ```
83
-
84
- ### find by hash
85
- ```
86
- let table = 'test';
87
-
88
- let hash = 'SHA256_TEST'
89
-
90
- let config = { // optional
91
- offset:0, length:10
92
- }
93
-
94
- ldb.findByHash( table,hash,config )
95
- .then( (response)=>{
96
- console.log( response );
97
- });
98
-
99
- ```
100
-
101
- ### push a new item at the end
102
- ```
103
- let table = 'test';
104
-
105
- let object = {
106
- name:'Peter',
107
- S: 'Male',
108
- age: 23,
109
- }
110
-
111
- ldb.push(table,object)
112
- .then( ()=>{ /* once finish */ });
113
-
114
- ```
115
-
116
- ### push a new item at the beginning
117
- ```
118
- let table = 'test';
119
-
120
- let object = {
121
- name:'Peter',
122
- S: 'Male',
123
- age: 23,
124
- }
125
-
126
- ldb.unshift(table,object)
127
- .then( ()=>{ /* once finish */ });
128
-
129
- ```
130
-
131
- ### place a new item in the middle
132
- ```
133
- let table = 'test';
134
-
135
- let line = 5; //if exist
136
-
137
- let object = {
138
- name:'Peter',
139
- S: 'Male',
140
- age: 23,
141
- }
142
-
143
- ldb.place(table,line,object)
144
- .then( ()=>{ /* once finish */ });
145
-
146
- ```
147
-
148
- ### replace an item
149
- ```
150
- let table = 'test';
151
-
152
- let hash = 'SHA256_TEST'
153
-
154
- let object = {
155
- name:'Peter',
156
- S: 'Male',
157
- age: 23,
158
- }
159
-
160
- ldb.replace(table,hash,object)
161
- .then( ()=>{ /* once finish */ });
162
-
163
- ```
164
-
165
- ### remove an item
166
- ```
167
- let table = 'test';
168
-
169
- let hash = 'SHA256_TEST'
170
-
171
- ldb.remove(table,hash)
172
- .then( ()=>{ /* once finish */ });
173
-
174
- ```
175
-
176
- ### remove the last item
177
- ```
178
- let table = 'test';
179
-
180
- ldb.pop(table)
181
- .then( ()=>{ /* once finish */ });
182
- ```
183
-
184
- ### remove the first item
185
- ```
186
- let table = 'test';
187
-
188
- ldb.shift(table)
189
- .then( ()=>{ /* once finish */ });
190
- ```
191
-
192
- ### remove a table
193
- ```
194
- let table = 'test';
195
-
196
- ldb.removeTable(table)
197
- .then( ()=>{ /* once finish */ });
198
-
199
- ```
package/main.js CHANGED
@@ -1,4 +1,5 @@
1
1
  const worker = require('worker_threads');
2
+ const fetch = require('axios');
2
3
  const url = require('url');
3
4
  const fs = require('fs');
4
5
 
@@ -15,11 +16,13 @@ function config( _config ) {
15
16
  /* --------------------------------------------------------------------------------------- */
16
17
 
17
18
  class molly_db{
19
+
18
20
  constructor( opt ){ if( opt.pass )
19
21
  this.pass = opt.pass; this.port = opt.port || 27017;
20
22
  this.path = opt.path.replace( /^\./,process.cwd() );
21
23
  return require(`${__dirname}/module/_worker_.js`)(this);
22
24
  }
25
+
23
26
  }
24
27
 
25
28
  /* --------------------------------------------------------------------------------------- */
package/module/_init_.js CHANGED
@@ -6,7 +6,9 @@ function fillDB( _db, _table, _path ){
6
6
 
7
7
  if( (/^http/).test(_path) ){ try{
8
8
  const stream = await fetch.get(_path,{responseType:'stream'});
9
- _itr = readline.createInterface({ input: stream })
9
+ _itr = readline.createInterface({
10
+ input: stream.data
11
+ })
10
12
  } catch(e) { console.log(`error reading ${_path}`); return response(); }}
11
13
 
12
14
  else if( fs.existsSync(_path) )
@@ -2,8 +2,8 @@ const worker = require('worker_threads');
2
2
  const readline = require('readline');
3
3
  const crypto = require('./_crypto_');
4
4
  const { Buffer } = require('buffer');
5
- const fetch = require('molly-fetch');
6
5
  const cluster = require('cluster');
6
+ const fetch = require('axios');
7
7
  const http = require('http');
8
8
  const url = require('url');
9
9
  const fs = require('fs');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "license": "MIT",
3
3
  "main": "main.js",
4
- "version": "1.0.20",
4
+ "version": "1.0.22",
5
5
  "name": "molly-db",
6
6
  "author": "bececrazy",
7
7
  "scripts": {
@@ -9,9 +9,9 @@
9
9
  },
10
10
  "repository": "https://github.com/EDBC-REPO-NPM/Molly-db",
11
11
  "dependencies": {
12
- "molly-fetch": "^1.0.8",
13
- "fs": "^0.0.1-security",
14
- "crypto-js": "^4.1.1"
12
+ "axios": "^0.27.2",
13
+ "crypto-js": "^4.1.1",
14
+ "fs": "^0.0.1-security"
15
15
  },
16
16
  "description": "Molly-db is a free and open source library for nodejs that allow you create a lightweight encrypted database using Json files",
17
17
  "keywords": [