This is an automated email from the ASF dual-hosted git repository.
daim pushed a commit to branch OAK-10823
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
The following commit(s) were added to refs/heads/OAK-10823 by this push:
new 1e58eb401e OAK-10823 : replaced db.collection.remove with
db.collection.deleteOne/deleteMany to make it compatible with both mongo &
mongosh
1e58eb401e is described below
commit 1e58eb401ed8bb7f27c29811db46fb39dd51c036
Author: Rishabh Kumar <[email protected]>
AuthorDate: Wed May 22 11:25:41 2024 +0530
OAK-10823 : replaced db.collection.remove with
db.collection.deleteOne/deleteMany to make it compatible with both mongo &
mongosh
---
oak-run/src/main/js/oak-mongo.js | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/oak-run/src/main/js/oak-mongo.js b/oak-run/src/main/js/oak-mongo.js
index b5a9439aed..64e54bb09b 100644
--- a/oak-run/src/main/js/oak-mongo.js
+++ b/oak-run/src/main/js/oak-mongo.js
@@ -301,32 +301,32 @@ var oak = (function(global){
var depth = pathDepth(path);
var id = depth + ":" + path;
// current node at path
- var result = db.nodes.remove({_id: id});
- count += result.nRemoved;
+ var result = db.nodes.deleteMany({_id: id});
+ count += result.deletedCount;
// might be a long path
- result = db.nodes.remove(longPathQuery(path));
- count += result.nRemoved;
+ result = db.nodes.deleteMany(longPathQuery(path));
+ count += result.deletedCount;
// descendants
var prefix = path + "/";
depth++;
while (true) {
- result = db.nodes.remove(longPathFilter(depth, prefix));
- count += result.nRemoved;
- result = db.nodes.remove({_id: pathFilter(depth++, prefix)});
- count += result.nRemoved;
- if (result.nRemoved == 0) {
+ result = db.nodes.deleteMany(longPathFilter(depth, prefix));
+ count += result.deletedCount;
+ result = db.nodes.deleteMany({_id: pathFilter(depth++, prefix)});
+ count += result.deletedCount;
+ if (result.deletedCount === 0) {
break;
}
}
// descendants further down the hierarchy with long path
while (true) {
- result = db.nodes.remove(longPathFilter(depth++, prefix));
- if (result.nRemoved == 0) {
+ result = db.nodes.deleteMany(longPathFilter(depth++, prefix));
+ if (result.deletedCount === 0) {
break;
}
- count += result.nRemoved;
+ count += result.deletedCount;
}
- return {nRemoved : count};
+ return {deletedCount : count};
};
/**
@@ -352,12 +352,12 @@ var oak = (function(global){
* @param {string} pattern the pattern to match the nodes to be removed.
*/
api.removeDescendantsAndSelfMatching = function(pattern) {
- var count = 0;
+ let count = 0;
db.nodes.find({_id: {$regex: pattern}}, {_id:
1}).forEach(function(doc) {
print("Removing " + doc._id + " and its children");
- var result = api.removeDescendantsAndSelf(api.pathFromId(doc._id));
- count += result.nRemoved;
- print("nRemoved : " + result.nRemoved);
+ const result =
api.removeDescendantsAndSelf(api.pathFromId(doc._id));
+ count += result.deletedCount;
+ print("nRemoved : " + result.deletedCount);
});
print("Total removed : " + count);
}