Mercurial > demo / examples/db/xdb/document.lisp
changeset 44: |
99d4ab4f8d53 |
parent: |
81b7333f27f8
|
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Sun, 11 Aug 2024 01:50:18 -0400 |
permissions: |
-rw-r--r-- |
description: |
update |
1 ;;; obj/db/document.lisp --- Database Document Objects 3 ;; Spliced from XDB, currently not in use outside of it 9 ((collection :initarg :collection 13 (doc-type :initarg :doc-type 17 (defmethod duplicate-doc-p ((doc document) test-doc) 19 (equal (key doc) (key test-doc)))) 21 (defmethod add ((doc document) &key collection duplicate-doc-p-func) 23 (if (slot-boundp doc 'collection) 24 (add-doc (or (collection doc) collection) (or duplicate-doc-p-func #'duplicate-doc-p)) 25 (error "Must specify collection to add document to.")))) 27 (defmethod get-val ((doc document) element &optional data-type) 28 (declare (ignore data-type)) 29 (if (slot-boundp doc element) 30 (slot-val doc element))) 32 (defmethod (setf get-val) (new-value (doc document) element &optional data-type) 33 (declare (ignore data-type)) 35 (setf (slot-value doc element) new-value))) 37 (defclass document-join (join-docs) 40 (defclass document-join-result (join-result) 43 (defmethod get-val ((composite-doc document-join-result) element &optional data-type) 44 (declare (ignore data-type)) 47 (cons (doc-type doc) (get-val doc element))) 48 (docs composite-doc))) 51 (defmethod get-doc ((collection document-join) value &key (element 'key) (test #'equal)) 55 (when (apply test (get-val doc element) value) 56 (return-from get-doc doc))) 60 (defmethod find-doc ((collection document-join) &key test) 65 (when (apply test doc) 66 (return-from find-doc doc)))