Created
April 25, 2013 04:39
-
-
Save mediocregopher/5457543 to your computer and use it in GitHub Desktop.
Given either a numeric id or name, returns all the children of that reference from sql. If the numeric id is given a normal select is done, if the name is given a subselect to get the id is done.
This file contains 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
(defn get-reference-children | |
[fn-id] ;fullname-or-id | |
(-> (select* reference) | |
(fields :id :fullname :isDir ) | |
(#(if-not (string? fn-id) | |
(where %1 {:parent_id fn-id}) | |
(where %1 {:parent_id (subselect reference | |
(fields :id) | |
(limit 1) | |
(where {:fullname fn-id}))} ))) | |
(exec))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment