datafolder 1.0.13 → 1.0.14
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/README.md +8 -0
- package/package.json +1 -1
- package/src/QyDB.js +6 -6
- package/src/rpc/evalCode.js +7 -0
- package/src/rpc/getFileContent.js +13 -0
- package/src/rpc/getRpcFiles.js +3 -0
- package/src/rpc/getSubItems.js +17 -0
- package/src/rpc/getTriggerFiles.js +3 -0
- package/src/rpc/queryFiles.js +4 -0
- package/src/rpc/reloadRpc.js +1 -0
package/README.md
CHANGED
|
@@ -4,6 +4,8 @@ datafolder is a lightning fluid JSON database for high speed SSDs, featuring an
|
|
|
4
4
|
|
|
5
5
|
### Changelog
|
|
6
6
|
|
|
7
|
+
1.0.14 Expire supports specifying milliseconds.
|
|
8
|
+
|
|
7
9
|
1.0.13 Added expire support to delete a dir in a specific future time.
|
|
8
10
|
|
|
9
11
|
1.0.12 Added expire support to expire a file or some properties of the JSON data in future.
|
|
@@ -173,6 +175,12 @@ dataFolder.expireDir("aitrainingdata/tmp", "2026-06-10T01:22:38.517Z");
|
|
|
173
175
|
dataFolder.expireFile("aitrainingdata/tmp/prompt", 3600);
|
|
174
176
|
dataFolder.expireContent("users/login", { sessionId: 300, token: 3600 });
|
|
175
177
|
|
|
178
|
+
// millisecond APIs (adding M at the end)
|
|
179
|
+
|
|
180
|
+
dataFolder.expireDirM("aitrainingdata/tmp", 1236); // expire after 1236 milliseconds
|
|
181
|
+
dataFolder.expireFileM("aitrainingdata/tmp/prompt", 1236); // expire after 1236 milliseconds
|
|
182
|
+
dataFolder.expireContentM("users/login", { sessionId: 300, token: 3600 }); // 300 and 3600 milliseconds
|
|
183
|
+
|
|
176
184
|
dataFolder.removeDirExpire("aitrainingdata/tmp");
|
|
177
185
|
dataFolder.removeFileExpire("aitrainingdata/tmp/prompt");
|
|
178
186
|
dataFolder.removeContentExpire("users/login", { sessionId: 1, token: 1 });
|
package/package.json
CHANGED
package/src/QyDB.js
CHANGED
|
@@ -33,21 +33,21 @@ import {
|
|
|
33
33
|
logger as m
|
|
34
34
|
} from "./QyLogger.js";
|
|
35
35
|
|
|
36
|
-
let
|
|
36
|
+
let p = e(n, "../data/sampleDataFolder");
|
|
37
37
|
|
|
38
|
-
class
|
|
38
|
+
class l extends t {
|
|
39
39
|
rootFolder;
|
|
40
40
|
options;
|
|
41
41
|
fetch;
|
|
42
42
|
batch;
|
|
43
43
|
_immediate;
|
|
44
44
|
creationTime;
|
|
45
|
-
constructor(e =
|
|
46
|
-
s(e) && (t = e, e =
|
|
45
|
+
constructor(e = p, t) {
|
|
46
|
+
s(e) && (t = e, e = p), super(), this.options = {
|
|
47
47
|
...o("QyDB"),
|
|
48
48
|
...t
|
|
49
49
|
}, this.rootFolder = e;
|
|
50
|
-
for (let i of [ "createIndex", "delIndex", "insert", "put", "remove", "delDir", "delFile", "delContent", "insertTrigger", "removeTrigger", "insertRpc", "removeRpc", "expireFile", "expireDir", "expireContent", "removeFileExpire", "removeDirExpire", "removeContentExpire" ]) this[i] = (...e) => {
|
|
50
|
+
for (let i of [ "createIndex", "delIndex", "insert", "put", "remove", "delDir", "delFile", "delContent", "insertTrigger", "removeTrigger", "insertRpc", "removeRpc", "expireFile", "expireDir", "expireContent", "expireFileM", "expireDirM", "expireContentM", "removeFileExpire", "removeDirExpire", "removeContentExpire" ]) this[i] = (...e) => {
|
|
51
51
|
var t = this.currentBatch;
|
|
52
52
|
return t[i].apply(t, e).run();
|
|
53
53
|
};
|
|
@@ -109,5 +109,5 @@ class d extends t {
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
export {
|
|
112
|
-
|
|
112
|
+
l as QyDB
|
|
113
113
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const Error_No_Such_File = new Error("No such file");
|
|
2
|
+
|
|
3
|
+
module.exports = ({ filePath, cChangeId: existingCChangeId }) => {
|
|
4
|
+
const file = dataFolder.fileP(filePath);
|
|
5
|
+
if (!file) return Error_No_Such_File;
|
|
6
|
+
const { fileContent, cChangeId, fileContentKey } = file;
|
|
7
|
+
const result = {};
|
|
8
|
+
if (existingCChangeId != cChangeId) {
|
|
9
|
+
Object.assign(result, { fileContent, cChangeId });
|
|
10
|
+
if (existingCChangeId == undefined) result.fileContentKey = fileContentKey;
|
|
11
|
+
}
|
|
12
|
+
return result;
|
|
13
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const Error_no_Such_Dir = new Error("No such dir");
|
|
2
|
+
|
|
3
|
+
module.exports = ({ dirPath, dChangeId, fChangeId }) => {
|
|
4
|
+
const dir = dataFolder.dirP(dirPath);
|
|
5
|
+
if (!dir) return Error_no_Such_Dir;
|
|
6
|
+
const result = {};
|
|
7
|
+
if (!(dChangeId || fChangeId)) {
|
|
8
|
+
result.fullPathHash = dir.fullPathHash;
|
|
9
|
+
}
|
|
10
|
+
if (dChangeId != dir.dChangeId) {
|
|
11
|
+
Object.assign(result, { subdirList: dir.sortedSubdirList.map((x) => x.name), dChangeId: dir.dChangeId });
|
|
12
|
+
}
|
|
13
|
+
if (fChangeId != dir.fChangeId) {
|
|
14
|
+
Object.assign(result, { fileList: dir.sortedFileList.map((x) => x.name), fChangeId: dir.fChangeId });
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = () => {};
|