Mercurial > demo / examples/db/xdb/proto.lisp
changeset 41: |
81b7333f27f8 |
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Sun, 16 Jun 2024 22:15:04 -0400 |
permissions: |
-rw-r--r-- |
description: |
more examples |
3 (defgeneric initialize-doc-container (collection) 5 "Create the docs container and set the collection's docs to the container. 6 If you specialize this then you have to specialize add-doc, store-doc, 7 sort-collection, sort-collection-temporary and union-collection. ")) 9 (defgeneric map-docs (result-type function collection &rest more-collections) 11 "Applies the function accross all the documents in the collection")) 13 (defgeneric duplicate-doc-p (doc test-doc) 14 (:method ((a t) (b t)))) 16 (defgeneric find-duplicate-doc (collection doc &key function) 17 (:documentation "Load collection from a file.")) 19 (defgeneric add-doc (collection doc &key duplicate-doc-p-func) 20 (:documentation "Add a document to the docs container.")) 22 (defgeneric store-doc (collection doc &key duplicate-doc-p-func) 23 (:documentation "Serialize the doc to file and add it to the collection.")) 25 (defgeneric serialize-doc (collection doc &key) 26 (:documentation "Serialize the doc to file.")) 28 (defgeneric serialize-docs (collection &key duplicate-doc-p-func) 29 (:documentation "Store all the docs in the collection on file and add it to the collection.")) 31 (defgeneric load-from-file (collection file) 32 (:documentation "Load collection from a file.")) 34 (defgeneric get-collection (db name) 35 (:documentation "Returns the collection by name.")) 37 (defgeneric add-collection (db name &key load-from-file-p) 38 (:documentation "Adds a collection to the db.")) 40 (defgeneric snapshot (collection) 41 (:documentation "Write out a snapshot.")) 43 (defgeneric load-db (db &key load-from-file-p) 44 (:documentation "Loads all the collections in a location.")) 46 (defgeneric get-docs (db collection-name &key return-type &allow-other-keys) 47 (:documentation "Returns the docs that belong to a collection.")) 49 (defgeneric get-doc (collection value &key element test) 50 (:documentation "Returns the docs that belong to a collection.")) 52 (defgeneric get-doc-complex (test element value collection &rest more-collections) 53 (:documentation "Returns the docs that belong to a collection.")) 55 (defgeneric get-doc-simple (element value collection &rest more-collections) 56 (:documentation "Returns the docs that belong to a collection.")) 58 (defgeneric find-doc (collection &key test) 59 (:documentation "Returns the docs that belong to a collection.")) 61 (defgeneric find-doc-complex (test collection &rest more-collections) 62 (:documentation "Returns the first doc that matches the test.")) 64 (defgeneric find-docs (return-type test collection)) 66 (defgeneric union-collection (return-type collection &rest more-collections)) 68 (defgeneric sort-collection (collection &key return-sort sort-value-func sort-test-func) 69 (:documentation "This sorts the collection 'permanantly'.")) 71 (defgeneric sort-collection-temporary (collection &key sort-value-func sort-test-func) 72 (:documentation "This does not sort the actual collection but returns an array 75 (defgeneric sum (collection &key function &allow-other-keys) 76 (:documentation "Applies the function to all the docs in the collection and returns the sum of 79 (defgeneric max-val (collection &key function element)) 82 (defgeneric add (doc &key collection duplicate-doc-p-func) 83 (:documentation "Add a document to the docs container.")) 86 (defgeneric write-object (object stream))