changelog shortlog graph tags branches changeset files revisions annotate raw help

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
1 (in-package :xdb)
2 
3 (defgeneric initialize-doc-container (collection)
4  (:documentation
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. "))
8 
9 (defgeneric map-docs (result-type function collection &rest more-collections)
10  (:documentation
11  "Applies the function accross all the documents in the collection"))
12 
13 (defgeneric duplicate-doc-p (doc test-doc)
14  (:method ((a t) (b t))))
15 
16 (defgeneric find-duplicate-doc (collection doc &key function)
17  (:documentation "Load collection from a file."))
18 
19 (defgeneric add-doc (collection doc &key duplicate-doc-p-func)
20  (:documentation "Add a document to the docs container."))
21 
22 (defgeneric store-doc (collection doc &key duplicate-doc-p-func)
23  (:documentation "Serialize the doc to file and add it to the collection."))
24 
25 (defgeneric serialize-doc (collection doc &key)
26  (:documentation "Serialize the doc to file."))
27 
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."))
30 
31 (defgeneric load-from-file (collection file)
32  (:documentation "Load collection from a file."))
33 
34 (defgeneric get-collection (db name)
35  (:documentation "Returns the collection by name."))
36 
37 (defgeneric add-collection (db name &key load-from-file-p)
38  (:documentation "Adds a collection to the db."))
39 
40 (defgeneric snapshot (collection)
41  (:documentation "Write out a snapshot."))
42 
43 (defgeneric load-db (db &key load-from-file-p)
44  (:documentation "Loads all the collections in a location."))
45 
46 (defgeneric get-docs (db collection-name &key return-type &allow-other-keys)
47  (:documentation "Returns the docs that belong to a collection."))
48 
49 (defgeneric get-doc (collection value &key element test)
50  (:documentation "Returns the docs that belong to a collection."))
51 
52 (defgeneric get-doc-complex (test element value collection &rest more-collections)
53  (:documentation "Returns the docs that belong to a collection."))
54 
55 (defgeneric get-doc-simple (element value collection &rest more-collections)
56  (:documentation "Returns the docs that belong to a collection."))
57 
58 (defgeneric find-doc (collection &key test)
59  (:documentation "Returns the docs that belong to a collection."))
60 
61 (defgeneric find-doc-complex (test collection &rest more-collections)
62  (:documentation "Returns the first doc that matches the test."))
63 
64 (defgeneric find-docs (return-type test collection))
65 
66 (defgeneric union-collection (return-type collection &rest more-collections))
67 
68 (defgeneric sort-collection (collection &key return-sort sort-value-func sort-test-func)
69  (:documentation "This sorts the collection 'permanantly'."))
70 
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
73 of sorted docs."))
74 
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
77 the return values."))
78 
79 (defgeneric max-val (collection &key function element))
80 
81 ;;; Document
82 (defgeneric add (doc &key collection duplicate-doc-p-func)
83  (:documentation "Add a document to the docs container."))
84 
85 ;;; Disk
86 (defgeneric write-object (object stream))