sorla-db 1.0.0 → 1.1.0

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/Brainstorming.md CHANGED
@@ -1,22 +1,22 @@
1
- For the first query version needs only to see if has some non logical operator or non logical comparison to resend to find as a recursive method.
2
-
3
- - Preparing sort of data using new capabilities
4
- - improving find behavior
5
-
6
- For comparison operators and deny operator like not
7
- adding nor https://www.mongodb.com/docs/manual/reference/operator/query/nor/
8
-
9
- https://www.mongodb.com/docs/manual/reference/operator/query-comparison/
10
- https://www.mongodb.com/docs/manual/reference/operator/query/expr/
11
- https://www.mongodb.com/docs/manual/reference/operator/query/regex/
12
-
13
-
14
- Preparing a bunch of misc tests to search data, add sort data and create test sortable data.
15
-
16
- //erros and improvements
17
- Bugs appears after resolving not, need to check and test why
18
- npm run test
19
-
20
- needs to improve projection to use cursor
21
-
1
+ For the first query version needs only to see if has some non logical operator or non logical comparison to resend to find as a recursive method.
2
+
3
+ - Preparing sort of data using new capabilities
4
+ - improving find behavior
5
+
6
+ For comparison operators and deny operator like not
7
+ adding nor https://www.mongodb.com/docs/manual/reference/operator/query/nor/
8
+
9
+ https://www.mongodb.com/docs/manual/reference/operator/query-comparison/
10
+ https://www.mongodb.com/docs/manual/reference/operator/query/expr/
11
+ https://www.mongodb.com/docs/manual/reference/operator/query/regex/
12
+
13
+
14
+ Preparing a bunch of misc tests to search data, add sort data and create test sortable data.
15
+
16
+ //erros and improvements
17
+ Bugs appears after resolving not, need to check and test why
18
+ npm run test
19
+
20
+ needs to improve projection to use cursor
21
+
22
22
  fix new bugs in test
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 Sysborg
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Sysborg
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,31 +1,216 @@
1
- # sorla-db
2
- A simple and temporary database focused to use in browser environment that will bring capabilities for other tools that will be launched as soon as possible.
3
-
4
- This idea is from our founder #andmarruda that give this idea and alot of this idea are developed by him.
5
-
6
- To create a minify file run
7
- ```
8
- node index.js
9
- ```
10
-
11
- To test the environment using jest run...
12
- Don`t forget to install the dev dependecies before, using:
13
-
14
- ```
15
- npm install --only=dev
16
- ```
17
-
18
- ```
19
- npm test
20
- ```
21
-
22
- Soon some documentations....
23
-
24
- Prohibited characters $ and .,
25
- $ because is used to call operators and . because uses to search key inside a object's object
26
-
27
- ## Find Operators
28
-
29
- ### $and
30
-
31
- The **$and** operator meticulously processes arrays, employing a loop chain mechanism. During this process, it's engineered for efficiency: if it encounters any comparison that yields **false**, it immediately halts the ongoing chain. This intelligent design is aimed at preventing unnecessary computation time, especially when dealing with documents that don't meet the specified condition. It's all about optimizing performance and ensuring swift, precise operations.
1
+ # sorla-db
2
+ A simple and temporary database focused to use in browser environment that will bring capabilities for other tools that will be launched as soon as possible.
3
+
4
+ This idea is from our founder #andmarruda that give this idea and alot of this idea are developed by him.
5
+
6
+ To create a minify file run
7
+ ```
8
+ node index.js
9
+ ```
10
+
11
+ To test the environment using jest run...
12
+ Don`t forget to install the dev dependecies before, using:
13
+
14
+ ```
15
+ npm install --only=dev
16
+ ```
17
+
18
+ ```
19
+ npm test
20
+ ```
21
+
22
+ Soon some documentations....
23
+
24
+ Prohibited characters $ and .,
25
+ $ because is used to call operators and . because uses to search key inside a object's object
26
+
27
+ ## Registering and creating a collection example
28
+ ```
29
+ window.sorla = new sorla();
30
+ window.sorla.createDb('tags');
31
+ window.sorla.useDb('tags');
32
+ window.sorla.db.createCollection('updatedTags');
33
+ window.sorla.db.updatedTags.insertMany([
34
+ {
35
+ name: 'Sonia',
36
+ age: 53
37
+ },
38
+ {
39
+ name: 'Anderson',
40
+ age: 36
41
+ }
42
+ ]);
43
+ ```
44
+
45
+ ## Find Operators
46
+
47
+ ### $and
48
+
49
+ The **$and** operator meticulously processes arrays, employing a loop chain mechanism. During this process, it's engineered for efficiency: if it encounters any comparison that yields **false**, it immediately halts the ongoing chain. This intelligent design is aimed at preventing unnecessary computation time, especially when dealing with documents that don't meet the specified condition. It's all about optimizing performance and ensuring swift, precise operations.
50
+
51
+ ### Example
52
+
53
+ ```
54
+ const results = window.sorla.db.updatedTags.find({
55
+ $and: [
56
+ {name: 'Anderson'},
57
+ {age: 36}
58
+ ]
59
+ });
60
+ ```
61
+
62
+ ### $or
63
+ The **$or** operator processes arrays, emploing a loop chain mechanism. During this process, it~s engineered for efficiency: if it enconters any comparison that yields **true**, it imediately halts
64
+ the ongoing chain. The intelligent design is aimed at preventing unnecessary computation time, especially when dealing with documents that the first condition matchs the needs. It's all about optimizing
65
+ performance and ensuring swift, precise operations.
66
+
67
+ ### Example
68
+
69
+ ```
70
+ const results = window.sorla.db.updatedTags.find({
71
+ $or: [
72
+ {name: 'Anderson'},
73
+ {age: 53}
74
+ ]
75
+ });
76
+ ```
77
+
78
+ ### $not
79
+ The **$not** operator processes the queries and invert the bool result, for example if {age: 36} return true for Anderson and false for Sonia then Sonia will be the one who will be returned,
80
+ remember about invert the boolean result? Anderson that is true becomes false and Sonia that is false becomes true.
81
+
82
+ ```
83
+ const results = window.sorla.db.updatedTags.find({
84
+ age: {
85
+ $not: {$eq: 36}
86
+ }
87
+ });
88
+ ```
89
+
90
+ ### $nor
91
+ The **$nor** operator returns the documents that match none of the queries in the array.
92
+
93
+ ```
94
+ const results = window.sorla.db.updatedTags.find({
95
+ $nor: [
96
+ {name: 'Anderson'},
97
+ {age: {$lt: 18}}
98
+ ]
99
+ });
100
+ ```
101
+
102
+ ### Nesting logical operators
103
+ **$and**, **$or** and **$nor** can be nested at any depth, and every query inside them can mix
104
+ fields and other logical operators. This returns everyone aged 30 or more whose name is Sonia
105
+ or who lives in A or B:
106
+
107
+ ```
108
+ const results = window.sorla.db.updatedTags.find({
109
+ $and: [
110
+ {age: {$gte: 30}},
111
+ {$or: [
112
+ {name: 'Sonia'},
113
+ {city: {$in: ['A', 'B']}}
114
+ ]}
115
+ ]
116
+ });
117
+ ```
118
+
119
+ ### More than one operator per field
120
+ A field condition can hold several operators and the document must satisfy all of them,
121
+ at the top level or inside any logical operator:
122
+
123
+ ```
124
+ const results = window.sorla.db.updatedTags.find({
125
+ $or: [
126
+ {age: {$gte: 30, $lte: 40}},
127
+ {name: 'Anderson'}
128
+ ]
129
+ });
130
+ ```
131
+
132
+ **$not** inverts the whole condition it wraps: `{age: {$not: {$gte: 30, $lte: 40}}}` returns
133
+ the documents whose age is *not* between 30 and 40. It must be used inside a field condition.
134
+
135
+ ### Missing fields and null
136
+ A document without the queried field does not match `$eq`, `$gt`, `$in`... but does match
137
+ `$ne` and `$nin`, like MongoDB. `null` can be used as a value: `{name: null}`.
138
+
139
+ Unknown operators and logical operators that do not receive an array throw an error.
140
+
141
+ ## Comparison operators
142
+
143
+ ### $eq
144
+ $eq get all the documents that has exactly the same value as requested.
145
+ For example if we ask age: { $eq: 53 }, will return one document in this example,
146
+ but in general pourpose will return all documents that age is equal than 53.
147
+
148
+ ```
149
+ const results = window.sorla.db.updatedTags.find({
150
+ age: { $eq: 36 }
151
+ });
152
+ ```
153
+
154
+ ### $ne
155
+ $ne or not equal operator search all lines that doens't have the inputed value.
156
+ For example $ne:36, will return 1 line in this example, but for general pourpose will
157
+ return all lines that age isn't 36.
158
+
159
+ ```
160
+ const results = window.sorla.db.updatedTags.find({
161
+ age: { $ne: 36 }
162
+ });
163
+ ```
164
+
165
+ ### $gt
166
+ $gt compares values that is greater than, for example everyone who have age above 20, all the documents will return in this example.
167
+ ```
168
+ const results = window.sorla.db.updatedTags.find({
169
+ age: { $gt: 36 }
170
+ });
171
+ ```
172
+
173
+ ### $gte
174
+ $gte compares values that is greater or equal than, for example everyone who have age above 20, all the documents will return in this example.
175
+ But if we put there for example greater or equal than 53, will return only one document.
176
+ ```
177
+ const results = window.sorla.db.updatedTags.find({
178
+ age: { $gte: 36 }
179
+ });
180
+ ```
181
+
182
+ ### $lt
183
+ $lt compares values that is smaller than, for example everyone who have age smaller than 30, in the documents in this example will return no one,
184
+ because no one has age smaller than 30.
185
+ ```
186
+ const results = window.sorla.db.updatedTags.find({
187
+ age: { $lt: 30 }
188
+ });
189
+ ```
190
+
191
+ ### $lte
192
+ $lte compares values that is smaller or equal than, for example veryone who have age smaller then 36, in the documents in this example will return one,
193
+ because Anderson has age of 36 that is equal 36, remember smaller or equal.
194
+ ```
195
+ const results = window.sorla.db.updatedTags.find({
196
+ age: { $lte: 36 }
197
+ });
198
+ ```
199
+
200
+ ### $in
201
+ $in operator compares if any value inside an array exists, like in operator in SQL, i will add a exemplo here that will return only one document.
202
+ Will return Anderson because age 36 exists is in array object.
203
+ ```
204
+ const results = window.sorla.db.updatedTags.find({
205
+ age: { $in: [36, 44]}
206
+ });
207
+ ```
208
+
209
+ ### $nin
210
+ $nin operator is opposite of $in operator, returns only documents that the values doesn't match with any of the query.
211
+ This will result in a total of 0 documents.
212
+ ```
213
+ const results = window.sorla.db.updatedTags.find({
214
+ age: { $nin: [36, 53]}
215
+ });
216
+ ```
package/debug-not.js CHANGED
@@ -1,24 +1,24 @@
1
- const sorla = require('./src/sorla.js');
2
- const helper = require('./src/helper.js');
3
-
4
- const numberOfObjects = 20;
5
- const sdb = new sorla();
6
- sdb.createDb('test');
7
- sdb.useDb('test');
8
-
9
- sdb.db.createCollection('collection_test');
10
-
11
- const objects = helper.createFakeCollection(sdb, 'collection_test', numberOfObjects);
12
- const [itemIndex1, ] = helper.getRandomComparisonData(objects);
13
-
14
- const finded = sdb.db.collection_test.find({
15
- uuid: {
16
- $not: {
17
- $eq: itemIndex1.uuid
18
- }
19
- }
20
- });
21
-
22
- console.log(finded.length, numberOfObjects);
23
-
1
+ const sorla = require('./src/sorla.js');
2
+ const helper = require('./src/helper.js');
3
+
4
+ const numberOfObjects = 20;
5
+ const sdb = new sorla();
6
+ sdb.createDb('test');
7
+ sdb.useDb('test');
8
+
9
+ sdb.db.createCollection('collection_test');
10
+
11
+ const objects = helper.createFakeCollection(sdb, 'collection_test', numberOfObjects);
12
+ const [itemIndex1, ] = helper.getRandomComparisonData(objects);
13
+
14
+ const finded = sdb.db.collection_test.find({
15
+ uuid: {
16
+ $not: {
17
+ $eq: itemIndex1.uuid
18
+ }
19
+ }
20
+ });
21
+
22
+ console.log(finded.length, numberOfObjects);
23
+
24
24
  //console.log(finded);