This is an automated email from the ASF dual-hosted git repository.
joscorbe pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
The following commit(s) were added to refs/heads/trunk by this push:
new 141d006215 OAK-10854: Allow oak.findOne to find long path documents
141d006215 is described below
commit 141d00621528d03c6e87d590b5488ea68b8689f4
Author: José Andrés Cordero Benítez <[email protected]>
AuthorDate: Mon Jun 3 15:59:37 2024 +0200
OAK-10854: Allow oak.findOne to find long path documents
---
oak-run/src/main/js/oak-mongo.js | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/oak-run/src/main/js/oak-mongo.js b/oak-run/src/main/js/oak-mongo.js
index 0924aa5ded..7ca0e4d218 100644
--- a/oak-run/src/main/js/oak-mongo.js
+++ b/oak-run/src/main/js/oak-mongo.js
@@ -656,13 +656,20 @@ var oak = (function(global){
* @memberof oak
* @method findOne
* @param {string} path the path of the document.
+ * @param {boolean} [longPaths=false] if true, it will extend the search
+ * to look for long paths.
* @returns {object} the document or null if it doesn't exist.
*/
- api.findOne = function(path) {
+ api.findOne = function(path, longPaths) {
if (path === undefined) {
return null;
}
- return db.nodes.findOne({_id: pathDepth(path) + ":" + path});
+ if (longPaths === undefined || longPaths === false) {
+ return db.nodes.findOne({_id: pathDepth(path) + ":" + path});
+ } else {
+ var depth = pathDepth(path);
+ return db.nodes.findOne(longPathFilter(depth, path));
+ }
};
/**