specter

Latest version: 1.1.3
luke.defeo 2018-06-17T22:36:57.000048Z

Hello, am i able to use spectres navigation to define what im looking for but return a structure several layers up, say for example i have the following data

(def ctx [
          {
           :id    "blah"
           :name  "News2"
           :rules [["<http://bbc.co.uk/sport|bbc.co.uk/sport>" "sport" "sport"]
                   ["<http://facebook.com|facebook.com>" "messages"]]}
          {
           :name  "News"
           :rules [["<http://bbc.co.uk|bbc.co.uk>" "sport"]
                   ["<http://facebook.com|facebook.com>" "messages"]]}
          {
           :name  "monitoring"
           :rules [["new-relic"]
                   ["stack driver"]]}])
And navigation :
(select-first [ALL :rules ALL ALL #(= % "stack driver")] ctx)
This will return the string “stack driver” is possible it returns its outer record
{
           :name  "monitoring"
           :rules [["new-relic"]
                   ["stack driver"]]}

manas_marthi 2018-06-17T22:47:01.000110Z

Hi Nathan, are there any sample data sets to try select and transform

nathanmarz 2018-06-17T22:49:17.000082Z

@luke.defeo use selected? for that

nathanmarz 2018-06-17T22:49:19.000074Z

(select-first [ALL (selected? :rules ALL ALL #(= % "stack driver"))] ctx)

nathanmarz 2018-06-17T22:50:24.000086Z

@manas.marthi you can use anything

nathanmarz 2018-06-17T22:50:42.000009Z

e.g. parse some html into a clojure data structure

nathanmarz 2018-06-17T22:51:07.000070Z

or just make up small toy examples like in the documentation

luke.defeo 2018-06-17T23:02:57.000015Z

@nathanmarz thanks a lot

manas_marthi 2018-06-17T23:09:03.000085Z

@nathanmarz thank you!