Created
January 11, 2022 20:09
-
-
Save nivb52/5191d58481bd750f08b607252bba3181 to your computer and use it in GitHub Desktop.
SQL/Posgress Query Builder Function
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 characters
| /** | |
| * @param jsonPath {String} | |
| * @example 'name.people.joe' returns 'name ->> people ->> joe' | |
| * @returns {String} | |
| */ | |
| function createSearchJsonQuery (jsonPath) { | |
| const add = jsonPath.split('.').join(' -> '); | |
| return (add.substring(0, add.lastIndexOf('->')) + ' ->> ' + add.substring(add.lastIndexOf('->') +3 )); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment