@iobroker/db-objects-redis 7.2.2 → 7.2.3-alpha.1-20260621-61726ea22
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/build/cjs/lib/objects/objectsInRedisClient.d.ts +654 -10
- package/build/cjs/lib/objects/objectsInRedisClient.js +467 -13
- package/build/cjs/lib/objects/objectsInRedisClient.js.map +2 -2
- package/build/cjs/lib/objects/objectsUtils.d.ts +63 -0
- package/build/cjs/lib/objects/objectsUtils.js.map +2 -2
- package/build/esm/lib/objects/objectsInRedisClient.d.ts +654 -10
- package/build/esm/lib/objects/objectsInRedisClient.d.ts.map +1 -1
- package/build/esm/lib/objects/objectsInRedisClient.js +470 -13
- package/build/esm/lib/objects/objectsInRedisClient.js.map +1 -1
- package/build/esm/lib/objects/objectsUtils.d.ts +63 -0
- package/build/esm/lib/objects/objectsUtils.d.ts.map +1 -1
- package/build/esm/lib/objects/objectsUtils.js +48 -0
- package/build/esm/lib/objects/objectsUtils.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -72,6 +72,9 @@ class ObjectsInRedisClient {
|
|
|
72
72
|
noLegacyMultihost;
|
|
73
73
|
userSubscriptions;
|
|
74
74
|
systemSubscriptions;
|
|
75
|
+
/**
|
|
76
|
+
* @param settings Settings for the objects client including connection and namespaces
|
|
77
|
+
*/
|
|
75
78
|
constructor(settings) {
|
|
76
79
|
this.settings = settings || {};
|
|
77
80
|
this.redisNamespace = `${this.settings.redisNamespace || this.settings.connection?.redisNamespace || "cfg"}.`;
|
|
@@ -126,6 +129,9 @@ class ObjectsInRedisClient {
|
|
|
126
129
|
throw new Error(`This host does not support protocol version "${protoVersion}"`);
|
|
127
130
|
}
|
|
128
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* Connect to the objects database and set up the change and file subscriptions
|
|
134
|
+
*/
|
|
129
135
|
connectDb() {
|
|
130
136
|
this.settings.connection = this.settings.connection || {};
|
|
131
137
|
const onChange = this.settings.change;
|
|
@@ -529,6 +535,9 @@ class ObjectsInRedisClient {
|
|
|
529
535
|
}
|
|
530
536
|
});
|
|
531
537
|
}
|
|
538
|
+
/**
|
|
539
|
+
* Get the current status of the database
|
|
540
|
+
*/
|
|
532
541
|
getStatus() {
|
|
533
542
|
return { type: "redis", server: false };
|
|
534
543
|
}
|
|
@@ -551,6 +560,11 @@ class ObjectsInRedisClient {
|
|
|
551
560
|
throw new Error(`${id} is not an object of type "meta"`);
|
|
552
561
|
}
|
|
553
562
|
}
|
|
563
|
+
/**
|
|
564
|
+
* Normalize a file name by collapsing slashes and backslashes into a single forward slash
|
|
565
|
+
*
|
|
566
|
+
* @param name The file name to normalize
|
|
567
|
+
*/
|
|
554
568
|
normalizeFilename(name) {
|
|
555
569
|
return name ? name.replace(/[/\\]+/g, "/") : name;
|
|
556
570
|
}
|
|
@@ -595,6 +609,13 @@ class ObjectsInRedisClient {
|
|
|
595
609
|
await this.client.publish(id, "null");
|
|
596
610
|
}
|
|
597
611
|
}
|
|
612
|
+
/**
|
|
613
|
+
* Build the internal redis key for a file
|
|
614
|
+
*
|
|
615
|
+
* @param id The id of the object owning the file
|
|
616
|
+
* @param name The file name
|
|
617
|
+
* @param isMeta Whether to return the key of the meta entry (true) or the data entry (false)
|
|
618
|
+
*/
|
|
598
619
|
getFileId(id, name, isMeta) {
|
|
599
620
|
name = this.normalizeFilename(name);
|
|
600
621
|
if (id.endsWith(".admin")) {
|
|
@@ -617,6 +638,15 @@ class ObjectsInRedisClient {
|
|
|
617
638
|
name = normalized.name;
|
|
618
639
|
return `${this.fileNamespace + id}$%$${name}${isMeta !== void 0 ? isMeta ? "$%$meta" : "$%$data" : ""}`;
|
|
619
640
|
}
|
|
641
|
+
/**
|
|
642
|
+
* Check whether the current options have the required rights on a file
|
|
643
|
+
*
|
|
644
|
+
* @param id The id of the object owning the file
|
|
645
|
+
* @param name The file name
|
|
646
|
+
* @param options The current request options including the user
|
|
647
|
+
* @param flag The access flag(s) to check for
|
|
648
|
+
* @param callback Called with whether the check failed and the effective options
|
|
649
|
+
*/
|
|
620
650
|
async checkFile(id, name, options2, flag, callback) {
|
|
621
651
|
const fileId = this.getFileId(id, name, true);
|
|
622
652
|
if (!fileId) {
|
|
@@ -646,6 +676,15 @@ class ObjectsInRedisClient {
|
|
|
646
676
|
}
|
|
647
677
|
return import_db_base.tools.maybeCallback(callback, true, options2);
|
|
648
678
|
}
|
|
679
|
+
/**
|
|
680
|
+
* Check whether the current user is allowed to access a file
|
|
681
|
+
*
|
|
682
|
+
* @param id The id of the object owning the file
|
|
683
|
+
* @param name The file name, or null for the whole namespace
|
|
684
|
+
* @param options The current request options including the user
|
|
685
|
+
* @param flag The access flag(s) to check for
|
|
686
|
+
* @param callback Called with the effective options once the rights have been checked
|
|
687
|
+
*/
|
|
649
688
|
checkFileRights(id, name, options2, flag, callback) {
|
|
650
689
|
return utils.checkFileRights(this, id, name, options2, flag, callback);
|
|
651
690
|
}
|
|
@@ -662,6 +701,11 @@ class ObjectsInRedisClient {
|
|
|
662
701
|
}
|
|
663
702
|
}
|
|
664
703
|
}
|
|
704
|
+
/**
|
|
705
|
+
* Set the default ACL applied to new objects and apply it to all existing objects without an ACL
|
|
706
|
+
*
|
|
707
|
+
* @param defaultNewAcl The default ACL to use, or null to use the built-in default
|
|
708
|
+
*/
|
|
665
709
|
async setDefaultAcl(defaultNewAcl) {
|
|
666
710
|
this.defaultNewAcl = defaultNewAcl || {
|
|
667
711
|
owner: CONSTS.SYSTEM_ADMIN_USER,
|
|
@@ -679,6 +723,12 @@ class ObjectsInRedisClient {
|
|
|
679
723
|
this.log.error(`${this.namespace} Could not update default acl: ${e.message}`);
|
|
680
724
|
}
|
|
681
725
|
}
|
|
726
|
+
/**
|
|
727
|
+
* Determine the groups and effective ACL of the given user
|
|
728
|
+
*
|
|
729
|
+
* @param user The id of the user to look up
|
|
730
|
+
* @param callback Called with the user, its groups and the effective ACL
|
|
731
|
+
*/
|
|
682
732
|
getUserGroup(user, callback) {
|
|
683
733
|
return utils.getUserGroup(this, user, (error, user2, userGroups, userAcl) => {
|
|
684
734
|
if (error) {
|
|
@@ -737,6 +787,15 @@ class ObjectsInRedisClient {
|
|
|
737
787
|
}
|
|
738
788
|
}
|
|
739
789
|
}
|
|
790
|
+
/**
|
|
791
|
+
* Write data into a file of an object
|
|
792
|
+
*
|
|
793
|
+
* @param id The id of the object owning the file
|
|
794
|
+
* @param name The file name
|
|
795
|
+
* @param data The data to write
|
|
796
|
+
* @param options The current request options including the user, or the callback
|
|
797
|
+
* @param callback Called once the file has been written
|
|
798
|
+
*/
|
|
740
799
|
async writeFile(id, name, data, options2, callback) {
|
|
741
800
|
if (typeof options2 === "function") {
|
|
742
801
|
callback = options2;
|
|
@@ -773,6 +832,14 @@ class ObjectsInRedisClient {
|
|
|
773
832
|
return this._writeFile(id, name, data, options3, callback, meta);
|
|
774
833
|
});
|
|
775
834
|
}
|
|
835
|
+
/**
|
|
836
|
+
* Promise-version of writeFile
|
|
837
|
+
*
|
|
838
|
+
* @param id The id of the object owning the file
|
|
839
|
+
* @param name The file name
|
|
840
|
+
* @param data The data to write
|
|
841
|
+
* @param options The current request options including the user
|
|
842
|
+
*/
|
|
776
843
|
writeFileAsync(id, name, data, options2) {
|
|
777
844
|
return new Promise((resolve, reject) => this.writeFile(id, name, data, options2, (err) => err ? reject(err) : resolve()));
|
|
778
845
|
}
|
|
@@ -791,6 +858,14 @@ class ObjectsInRedisClient {
|
|
|
791
858
|
}
|
|
792
859
|
return { file: buffer, mimeType };
|
|
793
860
|
}
|
|
861
|
+
/**
|
|
862
|
+
* Read a file of an object
|
|
863
|
+
*
|
|
864
|
+
* @param id The id of the object owning the file
|
|
865
|
+
* @param name The file name
|
|
866
|
+
* @param options The current request options including the user, or the callback
|
|
867
|
+
* @param callback Called with the file content and mime type
|
|
868
|
+
*/
|
|
794
869
|
readFile(id, name, options2, callback) {
|
|
795
870
|
if (typeof options2 === "function") {
|
|
796
871
|
callback = options2;
|
|
@@ -898,6 +973,14 @@ class ObjectsInRedisClient {
|
|
|
898
973
|
await this._delBinaryState(dataID);
|
|
899
974
|
await this.client.del(metaID);
|
|
900
975
|
}
|
|
976
|
+
/**
|
|
977
|
+
* Delete a file or directory of an object
|
|
978
|
+
*
|
|
979
|
+
* @param id The id of the object owning the file
|
|
980
|
+
* @param name The file or directory name to delete
|
|
981
|
+
* @param options The current request options including the user, or the callback
|
|
982
|
+
* @param callback Called with the list of removed files
|
|
983
|
+
*/
|
|
901
984
|
unlink(id, name, options2, callback) {
|
|
902
985
|
if (typeof options2 === "function") {
|
|
903
986
|
callback = options2;
|
|
@@ -927,12 +1010,34 @@ class ObjectsInRedisClient {
|
|
|
927
1010
|
}
|
|
928
1011
|
});
|
|
929
1012
|
}
|
|
1013
|
+
/**
|
|
1014
|
+
* Promise-version of unlink
|
|
1015
|
+
*
|
|
1016
|
+
* @param id The id of the object owning the file
|
|
1017
|
+
* @param name The file or directory name to delete
|
|
1018
|
+
* @param options The current request options including the user
|
|
1019
|
+
*/
|
|
930
1020
|
unlinkAsync(id, name, options2) {
|
|
931
1021
|
return new Promise((resolve, reject) => this.unlink(id, name, options2, (err) => err ? reject(err) : resolve()));
|
|
932
1022
|
}
|
|
1023
|
+
/**
|
|
1024
|
+
* Delete a file of an object (alias for unlink)
|
|
1025
|
+
*
|
|
1026
|
+
* @param id The id of the object owning the file
|
|
1027
|
+
* @param name The file name to delete
|
|
1028
|
+
* @param options The current request options including the user
|
|
1029
|
+
* @param callback Called once the file has been deleted
|
|
1030
|
+
*/
|
|
933
1031
|
delFile(id, name, options2, callback) {
|
|
934
1032
|
return this.unlink(id, name, options2, callback);
|
|
935
1033
|
}
|
|
1034
|
+
/**
|
|
1035
|
+
* Promise-version of delFile
|
|
1036
|
+
*
|
|
1037
|
+
* @param id The id of the object owning the file
|
|
1038
|
+
* @param name The file name to delete
|
|
1039
|
+
* @param options The current request options including the user
|
|
1040
|
+
*/
|
|
936
1041
|
delFileAsync(id, name, options2) {
|
|
937
1042
|
return this.unlinkAsync(id, name, options2);
|
|
938
1043
|
}
|
|
@@ -1069,6 +1174,14 @@ class ObjectsInRedisClient {
|
|
|
1069
1174
|
}
|
|
1070
1175
|
return import_db_base.tools.maybeCallbackWithError(callback, null, result2);
|
|
1071
1176
|
}
|
|
1177
|
+
/**
|
|
1178
|
+
* List the contents of a directory of an object
|
|
1179
|
+
*
|
|
1180
|
+
* @param id The id of the object owning the files
|
|
1181
|
+
* @param name The directory name to list
|
|
1182
|
+
* @param options The current request options including the user, or the callback
|
|
1183
|
+
* @param callback Called with the directory entries
|
|
1184
|
+
*/
|
|
1072
1185
|
readDir(id, name, options2, callback) {
|
|
1073
1186
|
if (typeof options2 === "function") {
|
|
1074
1187
|
callback = options2;
|
|
@@ -1096,6 +1209,13 @@ class ObjectsInRedisClient {
|
|
|
1096
1209
|
this._readDir(id, name, options3, callback);
|
|
1097
1210
|
});
|
|
1098
1211
|
}
|
|
1212
|
+
/**
|
|
1213
|
+
* Promise-version of readDir
|
|
1214
|
+
*
|
|
1215
|
+
* @param id The id of the object owning the files
|
|
1216
|
+
* @param name The directory name to list
|
|
1217
|
+
* @param options The current request options including the user
|
|
1218
|
+
*/
|
|
1099
1219
|
readDirAsync(id, name, options2) {
|
|
1100
1220
|
return new Promise((resolve, reject) => this.readDir(id, name, options2, (err, res) => err ? reject(err) : resolve(res)));
|
|
1101
1221
|
}
|
|
@@ -1197,6 +1317,15 @@ class ObjectsInRedisClient {
|
|
|
1197
1317
|
return import_db_base.tools.maybeCallbackWithRedisError(callback, e);
|
|
1198
1318
|
}
|
|
1199
1319
|
}
|
|
1320
|
+
/**
|
|
1321
|
+
* Rename a file or directory of an object
|
|
1322
|
+
*
|
|
1323
|
+
* @param id The id of the object owning the file
|
|
1324
|
+
* @param oldName The current file or directory name
|
|
1325
|
+
* @param newName The new file or directory name
|
|
1326
|
+
* @param options The current request options including the user, or the callback
|
|
1327
|
+
* @param callback Called once the file has been renamed
|
|
1328
|
+
*/
|
|
1200
1329
|
rename(id, oldName, newName, options2, callback) {
|
|
1201
1330
|
if (typeof options2 === "function") {
|
|
1202
1331
|
callback = options2;
|
|
@@ -1230,6 +1359,14 @@ class ObjectsInRedisClient {
|
|
|
1230
1359
|
this._rename(id, oldName, newName, options3, callback, meta);
|
|
1231
1360
|
});
|
|
1232
1361
|
}
|
|
1362
|
+
/**
|
|
1363
|
+
* Promise-version of rename
|
|
1364
|
+
*
|
|
1365
|
+
* @param id The id of the object owning the file
|
|
1366
|
+
* @param oldName The current file or directory name
|
|
1367
|
+
* @param newName The new file or directory name
|
|
1368
|
+
* @param options The current request options including the user
|
|
1369
|
+
*/
|
|
1233
1370
|
renameAsync(id, oldName, newName, options2) {
|
|
1234
1371
|
return new Promise((resolve, reject) => this.rename(id, oldName, newName, options2, (err) => err ? reject(err) : resolve()));
|
|
1235
1372
|
}
|
|
@@ -1249,6 +1386,14 @@ class ObjectsInRedisClient {
|
|
|
1249
1386
|
return import_db_base.tools.maybeCallbackWithRedisError(callback, e);
|
|
1250
1387
|
}
|
|
1251
1388
|
}
|
|
1389
|
+
/**
|
|
1390
|
+
* Update the modification time of a file
|
|
1391
|
+
*
|
|
1392
|
+
* @param id The id of the object owning the file
|
|
1393
|
+
* @param name The file name
|
|
1394
|
+
* @param options The current request options including the user, or the callback
|
|
1395
|
+
* @param callback Called once the file has been touched
|
|
1396
|
+
*/
|
|
1252
1397
|
touch(id, name, options2, callback) {
|
|
1253
1398
|
if (typeof options2 === "function") {
|
|
1254
1399
|
callback = options2;
|
|
@@ -1270,6 +1415,13 @@ class ObjectsInRedisClient {
|
|
|
1270
1415
|
return this._touch(id, name, callback, meta);
|
|
1271
1416
|
});
|
|
1272
1417
|
}
|
|
1418
|
+
/**
|
|
1419
|
+
* Promise-version of touch
|
|
1420
|
+
*
|
|
1421
|
+
* @param id The id of the object owning the file
|
|
1422
|
+
* @param name The file name
|
|
1423
|
+
* @param options The current request options including the user
|
|
1424
|
+
*/
|
|
1273
1425
|
touchAsync(id, name, options2) {
|
|
1274
1426
|
return new Promise((resolve, reject) => this.touch(id, name, options2, (err) => err ? reject(err) : resolve()));
|
|
1275
1427
|
}
|
|
@@ -1353,6 +1505,14 @@ class ObjectsInRedisClient {
|
|
|
1353
1505
|
return files;
|
|
1354
1506
|
}
|
|
1355
1507
|
}
|
|
1508
|
+
/**
|
|
1509
|
+
* Delete a file or directory of an object
|
|
1510
|
+
*
|
|
1511
|
+
* @param id The id of the object owning the file
|
|
1512
|
+
* @param name The file or directory name to delete
|
|
1513
|
+
* @param options The current request options including the user, or the callback
|
|
1514
|
+
* @param callback Called with the list of removed files
|
|
1515
|
+
*/
|
|
1356
1516
|
rm(id, name, options2, callback) {
|
|
1357
1517
|
if (typeof options2 === "function") {
|
|
1358
1518
|
callback = options2;
|
|
@@ -1379,10 +1539,25 @@ class ObjectsInRedisClient {
|
|
|
1379
1539
|
}
|
|
1380
1540
|
});
|
|
1381
1541
|
}
|
|
1542
|
+
/**
|
|
1543
|
+
* Promise-version of rm
|
|
1544
|
+
*
|
|
1545
|
+
* @param id The id of the object owning the file
|
|
1546
|
+
* @param name The file or directory name to delete
|
|
1547
|
+
* @param options The current request options including the user
|
|
1548
|
+
*/
|
|
1382
1549
|
rmAsync(id, name, options2) {
|
|
1383
1550
|
return new Promise((resolve, reject) => this.rm(id, name, options2, (err, files) => err ? reject(err) : resolve(files)));
|
|
1384
1551
|
}
|
|
1385
1552
|
// simulate. redis has no dirs
|
|
1553
|
+
/**
|
|
1554
|
+
* Create a directory for an object's files (simulated, as redis has no real directories)
|
|
1555
|
+
*
|
|
1556
|
+
* @param id The id of the object owning the files
|
|
1557
|
+
* @param dirName The directory name to create
|
|
1558
|
+
* @param options The current request options including the user, or the callback
|
|
1559
|
+
* @param callback Called once the directory has been created
|
|
1560
|
+
*/
|
|
1386
1561
|
mkdir(id, dirName, options2, callback) {
|
|
1387
1562
|
if (typeof options2 === "function") {
|
|
1388
1563
|
callback = options2;
|
|
@@ -1407,6 +1582,13 @@ class ObjectsInRedisClient {
|
|
|
1407
1582
|
this.writeFile(id, `${realName}_data.json`, "", options3, callback);
|
|
1408
1583
|
});
|
|
1409
1584
|
}
|
|
1585
|
+
/**
|
|
1586
|
+
* Promise-version of mkdir
|
|
1587
|
+
*
|
|
1588
|
+
* @param id The id of the object owning the files
|
|
1589
|
+
* @param dirName The directory name to create
|
|
1590
|
+
* @param options The current request options including the user
|
|
1591
|
+
*/
|
|
1410
1592
|
mkdirAsync(id, dirName, options2) {
|
|
1411
1593
|
return new Promise((resolve, reject) => this.mkdir(id, dirName, options2, (err) => err ? reject(err) : resolve()));
|
|
1412
1594
|
}
|
|
@@ -1525,6 +1707,14 @@ class ObjectsInRedisClient {
|
|
|
1525
1707
|
return import_db_base.tools.maybeCallbackWithError(callback, err, processed);
|
|
1526
1708
|
});
|
|
1527
1709
|
}
|
|
1710
|
+
/**
|
|
1711
|
+
* Change the owner and owner group of a file
|
|
1712
|
+
*
|
|
1713
|
+
* @param id The id of the object owning the file
|
|
1714
|
+
* @param name The file name
|
|
1715
|
+
* @param options The current request options including the new owner and the user
|
|
1716
|
+
* @param callback Called with the processed file(s)
|
|
1717
|
+
*/
|
|
1528
1718
|
chownFile(id, name, options2, callback) {
|
|
1529
1719
|
if (typeof options2 === "function") {
|
|
1530
1720
|
callback = options2;
|
|
@@ -1570,6 +1760,13 @@ class ObjectsInRedisClient {
|
|
|
1570
1760
|
return this._chownFile(id, name, options3, callback, meta);
|
|
1571
1761
|
});
|
|
1572
1762
|
}
|
|
1763
|
+
/**
|
|
1764
|
+
* Promise-version of chownFile
|
|
1765
|
+
*
|
|
1766
|
+
* @param id The id of the object owning the file
|
|
1767
|
+
* @param name The file name
|
|
1768
|
+
* @param options The current request options including the new owner and the user
|
|
1769
|
+
*/
|
|
1573
1770
|
chownFileAsync(id, name, options2) {
|
|
1574
1771
|
return new Promise((resolve, reject) => this.chownFile(id, name, options2, (err, processed) => err ? reject(err) : resolve(processed)));
|
|
1575
1772
|
}
|
|
@@ -1692,6 +1889,14 @@ class ObjectsInRedisClient {
|
|
|
1692
1889
|
}
|
|
1693
1890
|
this._chmodFileHelper(keysFiltered, objsFiltered, options2, (err) => import_db_base.tools.maybeCallbackWithError(callback, err, processed));
|
|
1694
1891
|
}
|
|
1892
|
+
/**
|
|
1893
|
+
* Change the file mode (permissions) of a single file
|
|
1894
|
+
*
|
|
1895
|
+
* @param id The id of the object owning the file
|
|
1896
|
+
* @param name The file name
|
|
1897
|
+
* @param options The current request options including the new mode and the user, or the callback
|
|
1898
|
+
* @param callback Called with the processed file
|
|
1899
|
+
*/
|
|
1695
1900
|
chmodFile(id, name, options2, callback) {
|
|
1696
1901
|
if (typeof options2 === "function") {
|
|
1697
1902
|
callback = options2;
|
|
@@ -1723,9 +1928,23 @@ class ObjectsInRedisClient {
|
|
|
1723
1928
|
return this._chmodFile(id, name, options3, callback, meta);
|
|
1724
1929
|
});
|
|
1725
1930
|
}
|
|
1931
|
+
/**
|
|
1932
|
+
* Promise-version of chmodFile
|
|
1933
|
+
*
|
|
1934
|
+
* @param id The id of the object owning the file
|
|
1935
|
+
* @param name The file name
|
|
1936
|
+
* @param options The current request options including the new mode and the user
|
|
1937
|
+
*/
|
|
1726
1938
|
chmodFileAsync(id, name, options2) {
|
|
1727
1939
|
return new Promise((resolve, reject) => this.chmodFile(id, name, options2, (err, processed) => err ? reject(err) : resolve(processed)));
|
|
1728
1940
|
}
|
|
1941
|
+
/**
|
|
1942
|
+
* Enable or disable the file cache
|
|
1943
|
+
*
|
|
1944
|
+
* @param enabled Whether the file cache should be enabled
|
|
1945
|
+
* @param options The current request options including the user, or the callback
|
|
1946
|
+
* @param callback Called with the resulting cache state
|
|
1947
|
+
*/
|
|
1729
1948
|
enableFileCache(enabled, options2, callback) {
|
|
1730
1949
|
if (typeof options2 === "function") {
|
|
1731
1950
|
callback = options2;
|
|
@@ -1741,6 +1960,12 @@ class ObjectsInRedisClient {
|
|
|
1741
1960
|
return import_db_base.tools.maybeCallbackWithError(callback, null, false);
|
|
1742
1961
|
});
|
|
1743
1962
|
}
|
|
1963
|
+
/**
|
|
1964
|
+
* Promise-version of enableFileCache
|
|
1965
|
+
*
|
|
1966
|
+
* @param enabled Whether the file cache should be enabled
|
|
1967
|
+
* @param options The current request options including the user
|
|
1968
|
+
*/
|
|
1744
1969
|
enableFileCacheAsync(enabled, options2) {
|
|
1745
1970
|
return new Promise((resolve, reject) => this.enableFileCache(enabled, options2, (err, res) => err ? reject(err) : resolve(res)));
|
|
1746
1971
|
}
|
|
@@ -1788,6 +2013,13 @@ class ObjectsInRedisClient {
|
|
|
1788
2013
|
}
|
|
1789
2014
|
}
|
|
1790
2015
|
}
|
|
2016
|
+
/**
|
|
2017
|
+
* Subscribe a user to file changes of an object
|
|
2018
|
+
*
|
|
2019
|
+
* @param id The id of the object owning the files
|
|
2020
|
+
* @param pattern One or more file name patterns to subscribe to
|
|
2021
|
+
* @param options The current request options including the user
|
|
2022
|
+
*/
|
|
1791
2023
|
subscribeUserFile(id, pattern, options2) {
|
|
1792
2024
|
return new Promise((resolve, reject) => {
|
|
1793
2025
|
utils.checkObjectRights(this, null, null, options2, "list", (err) => {
|
|
@@ -1799,6 +2031,13 @@ class ObjectsInRedisClient {
|
|
|
1799
2031
|
});
|
|
1800
2032
|
});
|
|
1801
2033
|
}
|
|
2034
|
+
/**
|
|
2035
|
+
* Unsubscribe a user from file changes of an object
|
|
2036
|
+
*
|
|
2037
|
+
* @param id The id of the object owning the files
|
|
2038
|
+
* @param pattern One or more file name patterns to unsubscribe from
|
|
2039
|
+
* @param options The current request options including the user
|
|
2040
|
+
*/
|
|
1802
2041
|
unsubscribeUserFile(id, pattern, options2) {
|
|
1803
2042
|
return new Promise((resolve, reject) => {
|
|
1804
2043
|
utils.checkObjectRights(this, null, null, options2, "list", (err) => {
|
|
@@ -1848,6 +2087,13 @@ class ObjectsInRedisClient {
|
|
|
1848
2087
|
return this._subscribe(pattern, false, callback);
|
|
1849
2088
|
});
|
|
1850
2089
|
}
|
|
2090
|
+
/**
|
|
2091
|
+
* Subscribe to object changes matching the given pattern
|
|
2092
|
+
*
|
|
2093
|
+
* @param pattern One or more patterns to subscribe to
|
|
2094
|
+
* @param options The current request options including the user, or the callback
|
|
2095
|
+
* @param callback Called once the subscription is registered
|
|
2096
|
+
*/
|
|
1851
2097
|
subscribe(pattern, options2, callback) {
|
|
1852
2098
|
if (typeof options2 === "function") {
|
|
1853
2099
|
callback = options2;
|
|
@@ -1855,9 +2101,22 @@ class ObjectsInRedisClient {
|
|
|
1855
2101
|
}
|
|
1856
2102
|
return this.subscribeConfig(pattern, options2, callback);
|
|
1857
2103
|
}
|
|
2104
|
+
/**
|
|
2105
|
+
* Promise-version of subscribe
|
|
2106
|
+
*
|
|
2107
|
+
* @param pattern One or more patterns to subscribe to
|
|
2108
|
+
* @param options The current request options including the user
|
|
2109
|
+
*/
|
|
1858
2110
|
subscribeAsync(pattern, options2) {
|
|
1859
2111
|
return new Promise((resolve, reject) => this.subscribe(pattern, options2, (err) => err ? reject(err) : resolve()));
|
|
1860
2112
|
}
|
|
2113
|
+
/**
|
|
2114
|
+
* Subscribe a user to object changes matching the given pattern
|
|
2115
|
+
*
|
|
2116
|
+
* @param pattern One or more patterns to subscribe to
|
|
2117
|
+
* @param options The current request options including the user, or the callback
|
|
2118
|
+
* @param callback Called once the subscription is registered
|
|
2119
|
+
*/
|
|
1861
2120
|
subscribeUser(pattern, options2, callback) {
|
|
1862
2121
|
if (typeof options2 === "function") {
|
|
1863
2122
|
callback = options2;
|
|
@@ -1870,6 +2129,12 @@ class ObjectsInRedisClient {
|
|
|
1870
2129
|
return this._subscribe(pattern, true, callback);
|
|
1871
2130
|
});
|
|
1872
2131
|
}
|
|
2132
|
+
/**
|
|
2133
|
+
* Promise-version of subscribeUser
|
|
2134
|
+
*
|
|
2135
|
+
* @param pattern One or more patterns to subscribe to
|
|
2136
|
+
* @param options The current request options including the user
|
|
2137
|
+
*/
|
|
1873
2138
|
subscribeUserAsync(pattern, options2) {
|
|
1874
2139
|
return new Promise((resolve, reject) => this.subscribeUser(pattern, options2, (err) => err ? reject(err) : resolve()));
|
|
1875
2140
|
}
|
|
@@ -1909,6 +2174,13 @@ class ObjectsInRedisClient {
|
|
|
1909
2174
|
}
|
|
1910
2175
|
});
|
|
1911
2176
|
}
|
|
2177
|
+
/**
|
|
2178
|
+
* Unsubscribe from object changes matching the given pattern
|
|
2179
|
+
*
|
|
2180
|
+
* @param pattern One or more patterns to unsubscribe from
|
|
2181
|
+
* @param options The current request options including the user, or the callback
|
|
2182
|
+
* @param callback Called once the subscription is removed
|
|
2183
|
+
*/
|
|
1912
2184
|
unsubscribe(pattern, options2, callback) {
|
|
1913
2185
|
if (typeof options2 === "function") {
|
|
1914
2186
|
callback = options2;
|
|
@@ -1916,9 +2188,22 @@ class ObjectsInRedisClient {
|
|
|
1916
2188
|
}
|
|
1917
2189
|
return this.unsubscribeConfig(pattern, options2, callback);
|
|
1918
2190
|
}
|
|
2191
|
+
/**
|
|
2192
|
+
* Promise-version of unsubscribe
|
|
2193
|
+
*
|
|
2194
|
+
* @param pattern One or more patterns to unsubscribe from
|
|
2195
|
+
* @param options The current request options including the user
|
|
2196
|
+
*/
|
|
1919
2197
|
unsubscribeAsync(pattern, options2) {
|
|
1920
2198
|
return new Promise((resolve, reject) => this.unsubscribe(pattern, options2, (err) => err ? reject(err) : resolve()));
|
|
1921
2199
|
}
|
|
2200
|
+
/**
|
|
2201
|
+
* Unsubscribe a user from object changes matching the given pattern
|
|
2202
|
+
*
|
|
2203
|
+
* @param pattern One or more patterns to unsubscribe from
|
|
2204
|
+
* @param options The current request options including the user, or the callback
|
|
2205
|
+
* @param callback Called once the subscription is removed
|
|
2206
|
+
*/
|
|
1922
2207
|
unsubscribeUser(pattern, options2, callback) {
|
|
1923
2208
|
if (typeof options2 === "function") {
|
|
1924
2209
|
callback = options2;
|
|
@@ -1936,6 +2221,12 @@ class ObjectsInRedisClient {
|
|
|
1936
2221
|
}
|
|
1937
2222
|
});
|
|
1938
2223
|
}
|
|
2224
|
+
/**
|
|
2225
|
+
* Promise-version of unsubscribeUser
|
|
2226
|
+
*
|
|
2227
|
+
* @param pattern One or more patterns to unsubscribe from
|
|
2228
|
+
* @param options The current request options including the user
|
|
2229
|
+
*/
|
|
1939
2230
|
unsubscribeUserAsync(pattern, options2) {
|
|
1940
2231
|
return new Promise((resolve, reject) => this.unsubscribeUser(pattern, options2, (err) => err ? reject(err) : resolve()));
|
|
1941
2232
|
}
|
|
@@ -2022,6 +2313,13 @@ class ObjectsInRedisClient {
|
|
|
2022
2313
|
return import_db_base.tools.maybeCallbackWithError(callback, null, filteredObjs);
|
|
2023
2314
|
}, true);
|
|
2024
2315
|
}
|
|
2316
|
+
/**
|
|
2317
|
+
* Change the owner and owner group of all objects matching the given pattern
|
|
2318
|
+
*
|
|
2319
|
+
* @param pattern The pattern of object ids whose owner should be changed
|
|
2320
|
+
* @param options The current request options including the new owner and the user, or the callback
|
|
2321
|
+
* @param callback Called with the list of changed objects
|
|
2322
|
+
*/
|
|
2025
2323
|
chownObject(pattern, options2, callback) {
|
|
2026
2324
|
if (typeof options2 === "function") {
|
|
2027
2325
|
callback = options2;
|
|
@@ -2062,6 +2360,12 @@ class ObjectsInRedisClient {
|
|
|
2062
2360
|
return this._chownObject(pattern, options3, callback);
|
|
2063
2361
|
});
|
|
2064
2362
|
}
|
|
2363
|
+
/**
|
|
2364
|
+
* Promise-version of chownObject
|
|
2365
|
+
*
|
|
2366
|
+
* @param pattern The pattern of object ids whose owner should be changed
|
|
2367
|
+
* @param options The current request options including the new owner and the user
|
|
2368
|
+
*/
|
|
2065
2369
|
chownObjectAsync(pattern, options2) {
|
|
2066
2370
|
return new Promise((resolve, reject) => this.chownObject(pattern, options2, (err, list) => err ? reject(err) : resolve(list)));
|
|
2067
2371
|
}
|
|
@@ -2123,6 +2427,13 @@ class ObjectsInRedisClient {
|
|
|
2123
2427
|
}
|
|
2124
2428
|
}, true);
|
|
2125
2429
|
}
|
|
2430
|
+
/**
|
|
2431
|
+
* Change the file mode (permissions) of all files matching the given pattern
|
|
2432
|
+
*
|
|
2433
|
+
* @param pattern The pattern of object ids whose files should be changed
|
|
2434
|
+
* @param options The current request options including the new mode and the user, or the callback
|
|
2435
|
+
* @param callback Called with the list of changed objects
|
|
2436
|
+
*/
|
|
2126
2437
|
chmodObject(pattern, options2, callback) {
|
|
2127
2438
|
if (typeof options2 === "function") {
|
|
2128
2439
|
callback = options2;
|
|
@@ -2152,6 +2463,12 @@ class ObjectsInRedisClient {
|
|
|
2152
2463
|
return this._chmodObject(pattern, options3, callback);
|
|
2153
2464
|
});
|
|
2154
2465
|
}
|
|
2466
|
+
/**
|
|
2467
|
+
* Promise-version of chmodObject
|
|
2468
|
+
*
|
|
2469
|
+
* @param pattern The pattern of object ids whose files should be changed
|
|
2470
|
+
* @param options The current request options including the new mode and the user
|
|
2471
|
+
*/
|
|
2155
2472
|
chmodObjectAsync(pattern, options2) {
|
|
2156
2473
|
return new Promise((resolve, reject) => this.chmodObject(pattern, options2, (err, list) => err ? reject(err) : resolve(list)));
|
|
2157
2474
|
}
|
|
@@ -2186,6 +2503,13 @@ class ObjectsInRedisClient {
|
|
|
2186
2503
|
}
|
|
2187
2504
|
return import_db_base.tools.maybeCallbackWithRedisError(callback, err, obj);
|
|
2188
2505
|
}
|
|
2506
|
+
/**
|
|
2507
|
+
* Get a single object by its id
|
|
2508
|
+
*
|
|
2509
|
+
* @param id The id of the object to read
|
|
2510
|
+
* @param options The current request options including the user, or the callback
|
|
2511
|
+
* @param callback Called with the read object
|
|
2512
|
+
*/
|
|
2189
2513
|
getObject(id, options2, callback) {
|
|
2190
2514
|
if (typeof options2 === "function") {
|
|
2191
2515
|
callback = options2;
|
|
@@ -2207,9 +2531,10 @@ class ObjectsInRedisClient {
|
|
|
2207
2531
|
}
|
|
2208
2532
|
}
|
|
2209
2533
|
/**
|
|
2534
|
+
* Promise-version of getObject
|
|
2210
2535
|
*
|
|
2211
|
-
* @param id
|
|
2212
|
-
* @param options
|
|
2536
|
+
* @param id The id of the object to read
|
|
2537
|
+
* @param options The current request options including the user
|
|
2213
2538
|
* @deprecated use `getObject` without callback instead
|
|
2214
2539
|
*/
|
|
2215
2540
|
getObjectAsync(id, options2) {
|
|
@@ -2278,6 +2603,14 @@ class ObjectsInRedisClient {
|
|
|
2278
2603
|
}
|
|
2279
2604
|
return import_db_base.tools.maybeCallbackWithError(callback, null, result2);
|
|
2280
2605
|
}
|
|
2606
|
+
/**
|
|
2607
|
+
* Get all object ids matching the given pattern
|
|
2608
|
+
*
|
|
2609
|
+
* @param pattern The pattern to match object ids against
|
|
2610
|
+
* @param options The current request options including the user, or the callback
|
|
2611
|
+
* @param callback Called with the matching keys
|
|
2612
|
+
* @param dontModify If true, the returned keys are not stripped of the namespace
|
|
2613
|
+
*/
|
|
2281
2614
|
getKeys(pattern, options2, callback, dontModify) {
|
|
2282
2615
|
if (typeof options2 === "function") {
|
|
2283
2616
|
callback = options2;
|
|
@@ -2295,8 +2628,14 @@ class ObjectsInRedisClient {
|
|
|
2295
2628
|
});
|
|
2296
2629
|
}
|
|
2297
2630
|
}
|
|
2298
|
-
|
|
2299
|
-
|
|
2631
|
+
/**
|
|
2632
|
+
* Promise-version of getKeys
|
|
2633
|
+
*
|
|
2634
|
+
* @param pattern The pattern to match object ids against
|
|
2635
|
+
* @param options The current request options including the user
|
|
2636
|
+
*/
|
|
2637
|
+
getKeysAsync(pattern, options2) {
|
|
2638
|
+
return this.getKeys(pattern, options2);
|
|
2300
2639
|
}
|
|
2301
2640
|
async _getObjects(keys2, options2, callback, dontModify) {
|
|
2302
2641
|
if (!keys2) {
|
|
@@ -2359,6 +2698,14 @@ class ObjectsInRedisClient {
|
|
|
2359
2698
|
}
|
|
2360
2699
|
return import_db_base.tools.maybeCallbackWithError(callback, null, result2);
|
|
2361
2700
|
}
|
|
2701
|
+
/**
|
|
2702
|
+
* Get multiple objects by their ids
|
|
2703
|
+
*
|
|
2704
|
+
* @param keys The ids of the objects to read
|
|
2705
|
+
* @param options The current request options including the user, or the callback
|
|
2706
|
+
* @param callback Called with the read objects
|
|
2707
|
+
* @param dontModify If true, the returned objects are not cloned/modified
|
|
2708
|
+
*/
|
|
2362
2709
|
getObjects(keys2, options2, callback, dontModify) {
|
|
2363
2710
|
if (typeof options2 === "function") {
|
|
2364
2711
|
callback = options2;
|
|
@@ -2382,6 +2729,12 @@ class ObjectsInRedisClient {
|
|
|
2382
2729
|
});
|
|
2383
2730
|
}
|
|
2384
2731
|
}
|
|
2732
|
+
/**
|
|
2733
|
+
* Promise-version of getObjects
|
|
2734
|
+
*
|
|
2735
|
+
* @param keys The ids of the objects to read
|
|
2736
|
+
* @param options The current request options including the user
|
|
2737
|
+
*/
|
|
2385
2738
|
getObjectsAsync(keys2, options2) {
|
|
2386
2739
|
return this.getObjects(keys2, options2);
|
|
2387
2740
|
}
|
|
@@ -2406,6 +2759,13 @@ class ObjectsInRedisClient {
|
|
|
2406
2759
|
}
|
|
2407
2760
|
this._getObjects(keys2, options2, callback, true);
|
|
2408
2761
|
}
|
|
2762
|
+
/**
|
|
2763
|
+
* Get all objects whose id matches the given pattern
|
|
2764
|
+
*
|
|
2765
|
+
* @param pattern The pattern to match object ids against
|
|
2766
|
+
* @param options The current request options including the user, or the callback
|
|
2767
|
+
* @param callback Called with the matching objects
|
|
2768
|
+
*/
|
|
2409
2769
|
getObjectsByPattern(pattern, options2, callback) {
|
|
2410
2770
|
if (typeof options2 === "function") {
|
|
2411
2771
|
callback = options2;
|
|
@@ -2426,6 +2786,12 @@ class ObjectsInRedisClient {
|
|
|
2426
2786
|
});
|
|
2427
2787
|
}
|
|
2428
2788
|
}
|
|
2789
|
+
/**
|
|
2790
|
+
* Promise-version of getObjectsByPattern
|
|
2791
|
+
*
|
|
2792
|
+
* @param pattern The pattern to match object ids against
|
|
2793
|
+
* @param options The current request options including the user
|
|
2794
|
+
*/
|
|
2429
2795
|
getObjectsByPatternAsync(pattern, options2) {
|
|
2430
2796
|
return new Promise((resolve, reject) => this.getObjectsByPattern(pattern, options2, (err, objs2) => err ? reject(err) : resolve(objs2)));
|
|
2431
2797
|
}
|
|
@@ -2574,7 +2940,7 @@ class ObjectsInRedisClient {
|
|
|
2574
2940
|
* This function writes the object into DB
|
|
2575
2941
|
*
|
|
2576
2942
|
* @param id ID of the object
|
|
2577
|
-
* @param obj
|
|
2943
|
+
* @param obj The object to write
|
|
2578
2944
|
* @param options options for access control are optional
|
|
2579
2945
|
* @param callback return function
|
|
2580
2946
|
*/
|
|
@@ -2602,10 +2968,11 @@ class ObjectsInRedisClient {
|
|
|
2602
2968
|
});
|
|
2603
2969
|
}
|
|
2604
2970
|
/**
|
|
2971
|
+
* Promise-version of setObject
|
|
2605
2972
|
*
|
|
2606
|
-
* @param id
|
|
2607
|
-
* @param obj
|
|
2608
|
-
* @param options
|
|
2973
|
+
* @param id ID of the object
|
|
2974
|
+
* @param obj The object to write
|
|
2975
|
+
* @param options options for access control are optional
|
|
2609
2976
|
* @deprecated use `setObject` without callback instead
|
|
2610
2977
|
*/
|
|
2611
2978
|
setObjectAsync(id, obj, options2) {
|
|
@@ -2662,6 +3029,13 @@ class ObjectsInRedisClient {
|
|
|
2662
3029
|
await this.client.publish(this.objNamespace + id, "null");
|
|
2663
3030
|
}
|
|
2664
3031
|
}
|
|
3032
|
+
/**
|
|
3033
|
+
* Delete an object
|
|
3034
|
+
*
|
|
3035
|
+
* @param id The id of the object to delete
|
|
3036
|
+
* @param options The current request options including the user, or the callback
|
|
3037
|
+
* @param callback Called once the object has been deleted
|
|
3038
|
+
*/
|
|
2665
3039
|
delObject(id, options2, callback) {
|
|
2666
3040
|
if (typeof options2 === "function") {
|
|
2667
3041
|
callback = options2;
|
|
@@ -2685,6 +3059,12 @@ class ObjectsInRedisClient {
|
|
|
2685
3059
|
}
|
|
2686
3060
|
});
|
|
2687
3061
|
}
|
|
3062
|
+
/**
|
|
3063
|
+
* Promise-version of delObject
|
|
3064
|
+
*
|
|
3065
|
+
* @param id The id of the object to delete
|
|
3066
|
+
* @param options The current request options including the user
|
|
3067
|
+
*/
|
|
2688
3068
|
delObjectAsync(id, options2) {
|
|
2689
3069
|
return this.delObject(id, options2);
|
|
2690
3070
|
}
|
|
@@ -3118,6 +3498,15 @@ class ObjectsInRedisClient {
|
|
|
3118
3498
|
throw new Error(`Cannot find view "${design}"`);
|
|
3119
3499
|
}
|
|
3120
3500
|
}
|
|
3501
|
+
/**
|
|
3502
|
+
* Run a predefined object view (design document) and return the matching rows
|
|
3503
|
+
*
|
|
3504
|
+
* @param design The design document name
|
|
3505
|
+
* @param search The view name within the design document
|
|
3506
|
+
* @param params Query parameters such as startkey and endkey
|
|
3507
|
+
* @param options The current request options including the user, or the callback
|
|
3508
|
+
* @param callback Called with the matching rows
|
|
3509
|
+
*/
|
|
3121
3510
|
getObjectView(design, search, params2, options2, callback) {
|
|
3122
3511
|
if (typeof options2 === "function") {
|
|
3123
3512
|
callback = options2;
|
|
@@ -3143,6 +3532,14 @@ class ObjectsInRedisClient {
|
|
|
3143
3532
|
});
|
|
3144
3533
|
}
|
|
3145
3534
|
}
|
|
3535
|
+
/**
|
|
3536
|
+
* Promise-version of getObjectView
|
|
3537
|
+
*
|
|
3538
|
+
* @param design The design document name
|
|
3539
|
+
* @param search The view name within the design document
|
|
3540
|
+
* @param params Query parameters such as startkey and endkey
|
|
3541
|
+
* @param options The current request options including the user
|
|
3542
|
+
*/
|
|
3146
3543
|
getObjectViewAsync(design, search, params2, options2) {
|
|
3147
3544
|
return this.getObjectView(design, search, params2, options2);
|
|
3148
3545
|
}
|
|
@@ -3202,6 +3599,13 @@ class ObjectsInRedisClient {
|
|
|
3202
3599
|
}
|
|
3203
3600
|
return result2;
|
|
3204
3601
|
}
|
|
3602
|
+
/**
|
|
3603
|
+
* Get the list of objects matching the given parameters
|
|
3604
|
+
*
|
|
3605
|
+
* @param params Query parameters such as startkey and endkey
|
|
3606
|
+
* @param options The current request options including the user, or the callback
|
|
3607
|
+
* @param callback Called with the matching objects
|
|
3608
|
+
*/
|
|
3205
3609
|
getObjectList(params2, options2, callback) {
|
|
3206
3610
|
if (typeof options2 === "function") {
|
|
3207
3611
|
callback = options2;
|
|
@@ -3227,6 +3631,12 @@ class ObjectsInRedisClient {
|
|
|
3227
3631
|
});
|
|
3228
3632
|
}
|
|
3229
3633
|
}
|
|
3634
|
+
/**
|
|
3635
|
+
* Promise-version of getObjectList
|
|
3636
|
+
*
|
|
3637
|
+
* @param params Query parameters such as startkey and endkey
|
|
3638
|
+
* @param options The current request options including the user
|
|
3639
|
+
*/
|
|
3230
3640
|
getObjectListAsync(params2, options2) {
|
|
3231
3641
|
return this.getObjectList(params2, options2);
|
|
3232
3642
|
}
|
|
@@ -3342,6 +3752,14 @@ class ObjectsInRedisClient {
|
|
|
3342
3752
|
return import_db_base.tools.maybeCallbackWithRedisError(callback, e);
|
|
3343
3753
|
}
|
|
3344
3754
|
}
|
|
3755
|
+
/**
|
|
3756
|
+
* Extend an existing object with the given partial object, creating it if it does not exist
|
|
3757
|
+
*
|
|
3758
|
+
* @param id The id of the object to extend
|
|
3759
|
+
* @param obj The partial object to merge into the existing object
|
|
3760
|
+
* @param options The current request options including the user, or the callback
|
|
3761
|
+
* @param callback Called with the resulting object and its id
|
|
3762
|
+
*/
|
|
3345
3763
|
extendObject(id, obj, options2, callback) {
|
|
3346
3764
|
if (typeof options2 === "function") {
|
|
3347
3765
|
callback = options2;
|
|
@@ -3360,16 +3778,23 @@ class ObjectsInRedisClient {
|
|
|
3360
3778
|
return this._extendObject(id, obj, options3, callback);
|
|
3361
3779
|
});
|
|
3362
3780
|
}
|
|
3781
|
+
/**
|
|
3782
|
+
* Promise-version of extendObject
|
|
3783
|
+
*
|
|
3784
|
+
* @param id The id of the object to extend
|
|
3785
|
+
* @param obj The partial object to merge into the existing object
|
|
3786
|
+
* @param options The current request options including the user
|
|
3787
|
+
*/
|
|
3363
3788
|
extendObjectAsync(id, obj, options2) {
|
|
3364
3789
|
return new Promise((resolve, reject) => this.extendObject(id, obj, options2 || null, (err, res) => err ? reject(err) : resolve(res)));
|
|
3365
3790
|
}
|
|
3366
3791
|
/**
|
|
3367
3792
|
* Returns the object id if found
|
|
3368
3793
|
*
|
|
3369
|
-
* @param idOrName
|
|
3370
|
-
* @param type
|
|
3371
|
-
* @param options
|
|
3372
|
-
* @param callback
|
|
3794
|
+
* @param idOrName The id or name to search for
|
|
3795
|
+
* @param type The expected common type, or null for any
|
|
3796
|
+
* @param options The current request options (may include a language)
|
|
3797
|
+
* @param callback Called with the found id and the original id/name
|
|
3373
3798
|
*/
|
|
3374
3799
|
_findObject(idOrName, type, options2, callback) {
|
|
3375
3800
|
this._getObject(idOrName, options2, (err, obj) => {
|
|
@@ -3413,6 +3838,14 @@ class ObjectsInRedisClient {
|
|
|
3413
3838
|
}, true);
|
|
3414
3839
|
});
|
|
3415
3840
|
}
|
|
3841
|
+
/**
|
|
3842
|
+
* Find an object by its id or name
|
|
3843
|
+
*
|
|
3844
|
+
* @param idOrName The id or name to search for
|
|
3845
|
+
* @param type The expected common type, or null for any
|
|
3846
|
+
* @param options The current request options (may include a language), or the callback
|
|
3847
|
+
* @param callback Called with the found id and the original id/name
|
|
3848
|
+
*/
|
|
3416
3849
|
findObject(idOrName, type, options2, callback) {
|
|
3417
3850
|
if (typeof type === "function") {
|
|
3418
3851
|
callback = type;
|
|
@@ -3439,6 +3872,11 @@ class ObjectsInRedisClient {
|
|
|
3439
3872
|
}
|
|
3440
3873
|
}
|
|
3441
3874
|
// can be called only from js-controller
|
|
3875
|
+
/**
|
|
3876
|
+
* Add object property paths that should be preserved when an object is overwritten (controller only)
|
|
3877
|
+
*
|
|
3878
|
+
* @param settings One or more property paths to preserve
|
|
3879
|
+
*/
|
|
3442
3880
|
addPreserveSettings(settings) {
|
|
3443
3881
|
if (!Array.isArray(settings)) {
|
|
3444
3882
|
settings = [settings];
|
|
@@ -3475,6 +3913,12 @@ class ObjectsInRedisClient {
|
|
|
3475
3913
|
return import_db_base.tools.maybeCallbackWithRedisError(callback, e);
|
|
3476
3914
|
}
|
|
3477
3915
|
}
|
|
3916
|
+
/**
|
|
3917
|
+
* Delete the whole objects database (requires admin rights)
|
|
3918
|
+
*
|
|
3919
|
+
* @param options The current request options including the user, or the callback
|
|
3920
|
+
* @param callback Called once the database has been destroyed
|
|
3921
|
+
*/
|
|
3478
3922
|
destroyDB(options2, callback) {
|
|
3479
3923
|
if (typeof options2 === "function") {
|
|
3480
3924
|
callback = options2;
|
|
@@ -3491,10 +3935,17 @@ class ObjectsInRedisClient {
|
|
|
3491
3935
|
return this._destroyDB(callback);
|
|
3492
3936
|
});
|
|
3493
3937
|
}
|
|
3938
|
+
/**
|
|
3939
|
+
* Promise-version of destroyDB
|
|
3940
|
+
*
|
|
3941
|
+
* @param options The current request options including the user
|
|
3942
|
+
*/
|
|
3494
3943
|
destroyDBAsync(options2) {
|
|
3495
3944
|
return new Promise((resolve, reject) => this.destroyDB(options2, (err) => err ? reject(err) : resolve()));
|
|
3496
3945
|
}
|
|
3497
|
-
|
|
3946
|
+
/**
|
|
3947
|
+
* Destructor of the class. Called when shutting down to close the redis connections.
|
|
3948
|
+
*/
|
|
3498
3949
|
async destroy() {
|
|
3499
3950
|
this.stop = true;
|
|
3500
3951
|
if (this.client) {
|
|
@@ -3522,6 +3973,9 @@ class ObjectsInRedisClient {
|
|
|
3522
3973
|
}
|
|
3523
3974
|
}
|
|
3524
3975
|
}
|
|
3976
|
+
/**
|
|
3977
|
+
* Load and register the Lua scripts used for atomic operations on the redis server
|
|
3978
|
+
*/
|
|
3525
3979
|
async loadLuaScripts() {
|
|
3526
3980
|
let luaDirName;
|
|
3527
3981
|
if (this.noLegacyMultihost && this.useSets) {
|