You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by jo...@apache.org on 2024/06/03 13:41:18 UTC

(jackrabbit-oak) branch OAK-10854 created (now 5233f76141)

This is an automated email from the ASF dual-hosted git repository.

joscorbe pushed a change to branch OAK-10854
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git


      at 5233f76141 OAK-10854: Allow oak.findOne to find long path documents.

This branch includes the following new commits:

     new 5233f76141 OAK-10854: Allow oak.findOne to find long path documents.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(jackrabbit-oak) 01/01: OAK-10854: Allow oak.findOne to find long path documents.

Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

joscorbe pushed a commit to branch OAK-10854
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git

commit 5233f7614162370d057e1e0565105ee9b32f6eaa
Author: Jose Cordero <co...@adobe.com>
AuthorDate: Mon Jun 3 15:41:01 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));
+        }
     };
 
     /**