document-dataply 0.0.3-alpha.2 → 0.0.3
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/LICENSE +21 -0
- package/dist/cjs/index.js +23 -2
- package/dist/types/core/document.d.ts +7 -0
- package/dist/types/types/index.d.ts +16 -0
- package/package.json +3 -3
- package/{README.md → readme.md} +8 -14
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 izure
|
|
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/dist/cjs/index.js
CHANGED
|
@@ -10045,6 +10045,18 @@ var DocumentDataply = class _DocumentDataply {
|
|
|
10045
10045
|
return deletedCount;
|
|
10046
10046
|
}, tx));
|
|
10047
10047
|
}
|
|
10048
|
+
/**
|
|
10049
|
+
* Count documents from the database that match the query
|
|
10050
|
+
* @param query The query to use (only indexed fields + _id allowed)
|
|
10051
|
+
* @param tx The transaction to use
|
|
10052
|
+
* @returns The number of documents that match the query
|
|
10053
|
+
*/
|
|
10054
|
+
async count(query, tx) {
|
|
10055
|
+
return this.api.readLock(() => this.api.runWithDefault(async (tx2) => {
|
|
10056
|
+
const pks = await this.getKeys(query);
|
|
10057
|
+
return pks.size;
|
|
10058
|
+
}, tx));
|
|
10059
|
+
}
|
|
10048
10060
|
/**
|
|
10049
10061
|
* Select documents from the database
|
|
10050
10062
|
* @param query The query to use (only indexed fields + _id allowed)
|
|
@@ -10065,6 +10077,7 @@ var DocumentDataply = class _DocumentDataply {
|
|
|
10065
10077
|
}
|
|
10066
10078
|
const {
|
|
10067
10079
|
limit = Infinity,
|
|
10080
|
+
offset = 0,
|
|
10068
10081
|
sortOrder = "asc",
|
|
10069
10082
|
orderBy: orderByField
|
|
10070
10083
|
} = options;
|
|
@@ -10092,17 +10105,25 @@ var DocumentDataply = class _DocumentDataply {
|
|
|
10092
10105
|
const cmp = aVal < bVal ? -1 : aVal > bVal ? 1 : 0;
|
|
10093
10106
|
return sortOrder === "asc" ? cmp : -cmp;
|
|
10094
10107
|
});
|
|
10095
|
-
const
|
|
10108
|
+
const start = offset;
|
|
10109
|
+
const end = limit === Infinity ? void 0 : start + limit;
|
|
10110
|
+
const limitedResults = results.slice(start, end);
|
|
10096
10111
|
for (const doc of limitedResults) {
|
|
10097
10112
|
yield doc;
|
|
10098
10113
|
}
|
|
10099
10114
|
} else {
|
|
10100
10115
|
let i = 0;
|
|
10116
|
+
let yieldedCount = 0;
|
|
10101
10117
|
for (const key of keys) {
|
|
10102
|
-
if (
|
|
10118
|
+
if (yieldedCount >= limit) break;
|
|
10119
|
+
if (i < offset) {
|
|
10120
|
+
i++;
|
|
10121
|
+
continue;
|
|
10122
|
+
}
|
|
10103
10123
|
const stringified = await self.api.select(key, false, tx2);
|
|
10104
10124
|
if (!stringified) continue;
|
|
10105
10125
|
yield JSON.parse(stringified);
|
|
10126
|
+
yieldedCount++;
|
|
10106
10127
|
i++;
|
|
10107
10128
|
}
|
|
10108
10129
|
}
|
|
@@ -149,6 +149,13 @@ export declare class DocumentDataply<T extends DocumentJSON, IC extends IndexCon
|
|
|
149
149
|
* @returns The number of deleted documents
|
|
150
150
|
*/
|
|
151
151
|
delete(query: Partial<DocumentDataplyIndexedQuery<T, IC>>, tx?: Transaction): Promise<number>;
|
|
152
|
+
/**
|
|
153
|
+
* Count documents from the database that match the query
|
|
154
|
+
* @param query The query to use (only indexed fields + _id allowed)
|
|
155
|
+
* @param tx The transaction to use
|
|
156
|
+
* @returns The number of documents that match the query
|
|
157
|
+
*/
|
|
158
|
+
count(query: Partial<DocumentDataplyIndexedQuery<T, IC>>, tx?: Transaction): Promise<number>;
|
|
152
159
|
/**
|
|
153
160
|
* Select documents from the database
|
|
154
161
|
* @param query The query to use (only indexed fields + _id allowed)
|
|
@@ -62,9 +62,25 @@ export interface DataplyTreeValue<T> {
|
|
|
62
62
|
k: number;
|
|
63
63
|
v: T;
|
|
64
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Options for querying documents.
|
|
67
|
+
*/
|
|
65
68
|
export type DocumentDataplyQueryOptions<T extends DocumentJSON, IC extends IndexConfig<T>> = {
|
|
69
|
+
/**
|
|
70
|
+
* The maximum number of documents to return.
|
|
71
|
+
*/
|
|
66
72
|
limit?: number;
|
|
73
|
+
/**
|
|
74
|
+
* The number of documents to skip.
|
|
75
|
+
*/
|
|
76
|
+
offset?: number;
|
|
77
|
+
/**
|
|
78
|
+
* The field to order the results by.
|
|
79
|
+
*/
|
|
67
80
|
orderBy?: ExtractIndexKeys<T, IC> | '_id';
|
|
81
|
+
/**
|
|
82
|
+
* The order to sort the results by.
|
|
83
|
+
*/
|
|
68
84
|
sortOrder?: BPTreeOrder;
|
|
69
85
|
};
|
|
70
86
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "document-dataply",
|
|
3
|
-
"version": "0.0.3
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Simple and powerful JSON document database supporting complex queries and flexible indexing policies.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "izure <admin@izure.org>",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"dataply"
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"dataply": "^0.0.19
|
|
45
|
+
"dataply": "^0.0.19"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/jest": "^30.0.0",
|
|
@@ -51,4 +51,4 @@
|
|
|
51
51
|
"ts-jest": "^29.4.6",
|
|
52
52
|
"typescript": "^5.9.3"
|
|
53
53
|
}
|
|
54
|
-
}
|
|
54
|
+
}
|
package/{README.md → readme.md}
RENAMED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|

|
|
2
|
+

|
|
2
3
|

|
|
3
4
|
|
|
4
5
|
# Document-Dataply
|
|
@@ -180,24 +181,17 @@ Flushes changes and closes the database files.
|
|
|
180
181
|
|
|
181
182
|
## Benchmark
|
|
182
183
|
|
|
183
|
-
|
|
184
|
+
Automated benchmarks are executed on every push to the `main` branch and for every pull request. This ensures that performance regressions are detected early.
|
|
184
185
|
|
|
185
|
-
- **
|
|
186
|
-
- **Batch
|
|
187
|
-
- **Iterations**: 5 full lifecycle cycles
|
|
186
|
+
- **Dataset**: 10,000 documents
|
|
187
|
+
- **Operations**: Batch Insert, Indexed Select, Partial Update, Full Update, Delete
|
|
188
188
|
|
|
189
|
-
###
|
|
189
|
+
### Performance Trend
|
|
190
190
|
|
|
191
|
-
|
|
192
|
-
| :--- | :---: | :---: | :---: | :---: | :---: | :--- |
|
|
193
|
-
| **InsertBatch** | 10,000 | 6499.22 | **1,538** | 5891.53 | 7403.67 | 1000 items per batch |
|
|
194
|
-
| **Select** | 100 | 30.09 | **3,323** | 26.09 | 37.16 | Indexed Equality |
|
|
195
|
-
| **Partial Update** | 100 | 86.44 | **1,157** | 74.15 | 115.22 | Bulk Update |
|
|
196
|
-
| **Full Update** | 1 | 20.77 | **48** | 16.10 | 25.61 | Single Update |
|
|
197
|
-
| **Delete** | 100 | 5893.65 | **17** | 5523.06 | 6173.39 | Page Reclamation |
|
|
191
|
+
You can view the real-time performance trend and detailed metrics on our [Performance Dashboard](https://izure1.github.io/document-dataply/dev/bench/).
|
|
198
192
|
|
|
199
|
-
> [!
|
|
200
|
-
> **
|
|
193
|
+
> [!TIP]
|
|
194
|
+
> **Continuous Monitoring**: We use `github-action-benchmark` to monitor performance changes. For every PR, a summary of the performance impact is automatically commented to help maintain high efficiency.
|
|
201
195
|
|
|
202
196
|
## License
|
|
203
197
|
|