Permalink
Browse files

Added ability to query for what keys are in a document

Added GET-KEYS on a document. This is useful in a heterogenous
collection where different documents may need to be queried.
  • Loading branch information...
1 parent 90cfd35 commit 6c8c7f6117ef86cef194ac98dbfd6358be47efd2 @pnathan pnathan committed Jan 12, 2012
Showing with 7 additions and 0 deletions.
  1. +6 −0 src/document.lisp
  2. +1 −0 src/packages.lisp
View
@@ -58,6 +58,12 @@ the document was generated by the client (as opposed to having been read from th
(push (doc-id document) lst))
lst))
+(defgeneric get-keys (document)
+ (:documentation "Gets a list of keys that are in the document"))
+(defmethod get-keys ((document document))
+ (loop for key being the hash-keys of (elements document)
+ collect key))
+
(defun get-all-values (key list-of-docs)
(let ((lst ()))
(dolist (doc list-of-docs)
View
@@ -17,6 +17,7 @@
:ht->document
:mapdoc
:doc-id
+ :get-keys
;;commands
:mongo

0 comments on commit 6c8c7f6

Please sign in to comment.