Hi Alex, I have a couple of follow up Pilog questions.I've been doing some trial and error and I don't see it converging :)
I have written a statndalone script for this so that you can easily tell me how to do it in it. In the script below, the entity relation defines three types - Item, Status and Tag. An Item can have a title, status and 0 or more tags. I am able to query "all items", "all open/closed items", "all items where one of the tags match" The parts where I am struggling with are the following - 1. Query all open items that have the given tags 2. Query all items that have "ALL" the given tags - for example all items tagged with RED and GREEN -> this should only generate ITEM3 Also, I'd love some feedback for the appropriateness of the ER model that I've defined. Regards, Kashyap (pool "test.db") (class +Item +Entity) (rel ttl (+IdxFold +String)) (rel tgs (+List +Joint) itm (+Tag)) (rel sts (+Ref +Link) NIL (+Satus)) (class +Tag +Entity) (rel itm (+Joint) tgs (+Item)) (rel nm (+IdxFold +String)) (class +Status +Entity) (rel nm (+IdxFold +String)) (de new-status (Nm) (new! '(+Status) 'nm Nm) ) (de new-item (Ttl Sts Tgs) (let N (new '(+Item) 'ttl Ttl 'sts Sts) (for Tg Tgs (put> N 'tgs (new! '(+Tag) 'nm Tg 'itm N)) ) (commit) ) ) (de print-header (H) (prinl) (prinl H) (prinl (pack (mapcar '( (I) "-") (range 1 (length H)))) ) ) (de print-item (I) (prinl (get I 'ttl) ": " (get (get I 'sts) 'nm) " [" (glue ", " (mapcar '( (O) (get O 'nm)) (get I 'tgs) ) ) "]" ) ) (unless (seq *DB) (prinl "Initializing DB") (let ( SO (new-status "OPEN") SC (new-status "CLOSED") RED "RED" BLUE "BLUE" GREEN "GREEN") (new-item "ITEM1" SO (list RED BLUE)) (new-item "ITEM2" SC (list RED)) (new-item "ITEM3" SC (list GREEN RED)) (new-item "ITEM4" SC (list RED)) (new-item "ITEM5" SO (list BLUE)) ) ) (de all-items () (for I (collect 'ttl '+Item) (print-item I) ) ) (print-header "All Items") (all-items) (de open-items () (let R (make (pilog (quote @St "Open" (select (@Item) ( (nm +Status @St (sts +Item)) ) ) ) (link @Item) ) ) R ) ) (print-header "Open Items") (for I (open-items) (print-item I)) (de blue-or-green-items () (let R (make (pilog (quote @BLUE "BLUE" @GREEN "GREEN" (select (@Item) ( (nm +Tag @BLUE itm) (nm +Tag @GREEN itm) ) ) ) (link @Item) ) ) R ) ) (print-header "Blue Or Green Items") (for I (blue-or-green-items) (print-item I)) On Tue, Nov 5, 2019 at 6:06 AM C K Kashyap <ckkash...@gmail.com> wrote: > Thanks Alex, > The concatenation of multiple collects is just what I need :) > Regards, > Kashyap > > On Tue, Nov 5, 2019 at 4:59 AM Alexander Burger <a...@software-lab.de> > wrote: > >> Hi Kashyap, >> >> > My ER model looks like this - >> > (class +Task +Entity) >> > (rel ttl (+IdxFold +String)) >> > ... >> > (rel upds (+List +Joint) tsk (+Update)) >> > ... >> > (class +Update +Entity) >> > (rel tsk (+Joint) upds (+Task) ) >> > (rel dsc (+Sn +IdxFold +String)) >> > ... >> > How can I select all the Tasks that have a given text that either >> matches >> > the title of the +Task (ttl) or the description of an +Update (dsc)? >> >> Normal usage of two 'select' generators will not do this, as they imply >> an AND. >> A combined generator is not usable, I think, due to the different >> structure. >> >> So you could use nested queries (see doc/select.html) if you need >> 'select' (e.g. >> because you want to make a more general search over other keys too), or >> simply >> traverse both trees one after the other (i.e. an OR). >> >> The latter one is the simplest: >> >> (let Text (...) >> (uniq >> (conc >> (collect 'ttl '+Task Text) >> (collect 'dsc '+Update Text Text 'tsk) ) ) ) >> >> (Not tested) >> >> ☺/ A!ex >> >> -- >> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe >> >