Browse Source

Wrote some queries

Samuel W. Flint 10 years ago
parent
commit
5be063154b
1 changed files with 38 additions and 0 deletions
  1. 38 0
      database.lisp

+ 38 - 0
database.lisp

@@ -119,3 +119,41 @@
                     :/marriage marriage-id
                     :/divorce-date date))
       divorce-id)))
+
+
+;;; Query records
+;;; Get Person
+(defun get-person (id)
+  (with-tx
+    (first
+     (select :people
+             (where (equal :/person-id id))))))
+
+;;; Get Birth record (by person)
+(defun get-birth (id)
+  (with-tx
+    (first
+     (select :births
+             (where (equal :/birth-person id))))))
+
+;;; Get Death Record
+(defun get-death (id)
+  (with-tx
+    (first
+     (select :deaths
+             (where (equal :/death-person id))))))
+
+;;; get marriage (by husband/wife)
+(defun get-marriage (husband wife)
+  (with-tx
+    (first
+     (select :marriages
+             (where (and (equal :/wife wife)
+                       (equal :/husband husband)))))))
+
+;;; get divorce (by marriage)
+(defun get-divorce (id)
+  (with-tx
+    (first
+     (select :divorces
+             (where (equal :/marriage id))))))