Last active
April 25, 2023 15:01
-
-
Save AnechaS/2a6d52b1ec8fc92facaec226a75fa090 to your computer and use it in GitHub Desktop.
Revisions
-
AnechaS revised this gist
Apr 25, 2023 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,7 @@ /** * Find property path in the object with a value * @param {object} obj * @param {any} value * @return {string} */ function findPropertyPathWithValue(obj, value) { -
AnechaS revised this gist
May 21, 2021 . 1 changed file with 0 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +0,0 @@ -
AnechaS renamed this gist
May 21, 2021 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,3 @@ findPropertyPathWithValue( { firstname: { -
AnechaS revised this gist
May 21, 2021 . 2 changed files with 10 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ // Example findPropertyPathWithValue( { firstname: { $inQuery: { className: "UserDetail", where: { firstname: "{{value}}" } }, }, }, "{{value}}" ); // => firstname.$inQuery.where.firstname This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,13 +18,3 @@ function findPropertyPathWithValue(obj, value) { } } } -
AnechaS created this gist
May 21, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ /** * Find property path in the object with a value * * @param {object} obj * @param {any} value * * @return {string} */ function findPropertyPathWithValue(obj, value) { for (const key in obj) { if (JSON.stringify(value) === JSON.stringify(obj[key])) { return key; } else if (typeof obj[key] === 'object') { const pathname = findPropertyPathWithValue(obj[key], value); if (pathname) { return key + '.' + pathname; } } } } // Example findPropertyPathWithValue( { firstname: { $inQuery: { className: "UserDetail", where: { firstname: "{{value}}" } }, }, }, "{{value}}" ); // => firstname.$inQuery.where.firstname