Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ../pil21/pil plisp.l -rule~main -go +
- # http://localhost:8080/?-A67
- (allowed NIL
- "@lib.css" "!rule.json" "!test.json")
- (load "@lib/http.l" "@lib/xhtml.l" "@lib/json.l")
- (symbols 'rule 'pico)
- ### DB ###
- (class +Rule +Entity)
- (dm T @ (put> This 'id (genKey 'id '+Rule)) (pass super))
- (rel id (+Need +Key +Number)) #Id
- (rel name (+String)) # Name
- (rel version (+Number))
- (rel updatedAt (+Number))
- (rel createdAt (+Number))
- (rel result (+Ref +String))
- (rel content (+Ref +String))
- (rel ruleType (+Joint) ruleTypes (+RuleType))
- (class +RuleType +Entity)
- (dm T @ (put> This 'id (genKey 'id '+RuleType)) (pass super))
- (rel id (+Need +Key +Number)) #RuleType
- (rel name (+Idx +String))
- (dbs
- (0)
- (1 +RuleType)
- (2 +Rule)
- (2 (+RuleType id name))
- (3 (+Rule name))
- (2 (+Rule id))
- )
- #
- (de test ()
- (request! '(+RuleType) 'name "Test")
- )
- (de test.json (This)
- (msg This)
- (test)
- (httpHead "application/json" 0)
- (ht:Out *Chunked
- (printJson "I have added something into database")))
- (de rule.json (This)
- (httpHead "application/json" 0)
- (msg This)
- (ht:Out *Chunked
- (printJson
- (mapcar
- '((X)
- (cons
- (cdr X)
- (cond
- ((num? V) (datStr V)) # Can only be date
- ((isa '+RuleType V) (do
- (msg "df")
- ( ; V nm
- )))
- ((isa '+Rule V) (; V nm
- ))
- ((pair V) (mapcar '((This) (: nm)) V) )
- (T V))))
- (db 'name '+RuleType This)))))
- ### RUN ###
- (de main ()
- (symbols '(rule pico))
- (pool "rule/" *Dbs) )
- (de go ()
- (rollback)
- (server 8080 '("!test.json" "!rule.json")) )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement