Rename collections to db

parent 90f5f7d5
......@@ -22,10 +22,10 @@
(define users-name
(make-parameter #f)) ; set this to a string
;; The "database" of this instance, which keeps track of collections.
;; The "collections database" of this instance.
;; This is a hashtable where keys are collection names and values are
;; lists of items.
(define db
(define collections
(make-parameter #f)) ; set this to a mutable hasheq
;; The "magenc" store is where we store encrypted chunks of data.
......@@ -112,7 +112,7 @@
(h2 "Most recent post in your "
(a (@ (href ,(golem-url col-handler)))
,col-name))
,(match (db-ref col-sym)
,(match (collections-ref col-sym)
['()
'(p (i "Hey look... nothing!"))]
[(list post-uri posts-uris ...)
......@@ -235,7 +235,7 @@
;; We set things up enough to pass it off for federation, so at this
;; point we should add it to our outbox.
(db-append! 'outbox create-url)
(collections-append! 'outbox create-url)
;; Now render a template saying we saved it.
;; TODO: We should redirect.
(render-ok (generic-base-tmpl
......@@ -373,27 +373,27 @@
(define object
(store-get-json (string->url (hash-ref activity 'object))
(hungry-store)))
(db-append! 'inbox activity-url)))
(collections-append! 'inbox activity-url)))
(void))
;;; Database stuff
;;; ==============
;; The "database" is simply a mutable hashtable where keys are
;; symbols and values are lists of items.
;; The "collections database" is simply a mutable hashtable where keys
;; are symbols and values are lists of items.
;; Append VAL to COLLECTION in the global db
(define/contract (db-append! collection val)
(define/contract (collections-append! collection val)
(-> symbol? any/c void?)
(hash-set! (db) collection
(cons val (hash-ref (db) collection '())))
(hash-set! (collections) collection
(cons val (hash-ref (collections) collection '())))
(void))
;; Fetch all items from COLLECTION in the global DB
(define/contract (db-ref collection)
;; Fetch all items from COLLECTION in the global COLLECTIONS
(define/contract (collections-ref collection)
(-> symbol? (or/c pair? null?)) ; technically list? but that's pricey :)
(hash-ref (db) collection '()))
(hash-ref (collections) collection '()))
;;; Store stuff
;;; ===========
......@@ -424,7 +424,7 @@
#f '() '() #f)]
#:other-stores [other-stores_ '()])
(parameterize ([users-name users-name_]
[db (make-hasheq)]
[collections (make-hasheq)]
[magenc-store magenc-store_]
[base-url base-url_]
[other-stores other-stores_])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment