Permalink
Browse files

fixed rm; some get-element changes

  • Loading branch information...
1 parent ab67d10 commit 90cfd3581a7b1fe09459dce01eab02001d709314 @fons committed Nov 22, 2011
Showing with 5 additions and 2 deletions.
  1. +4 −1 src/document.lisp
  2. +1 −1 src/shell.lisp
View
@@ -38,6 +38,7 @@ the document was generated by the client (as opposed to having been read from th
(setf (gethash key (elements document)) value)
(call-next-method))
+
(defgeneric get-element ( key document)
( :documentation "Get an element identified by key from the document. To get the _id use :_id as the key" ) )
@@ -70,10 +71,11 @@ the document was generated by the client (as opposed to having been read from th
(dolist (key key-list)
(typecase iter-doc
(document (multiple-value-bind (doc doc-exists-p) (gethash key (elements iter-doc))
- (setf iter-doc doc exists-p doc-exists-p)))
+ (setf iter-doc doc exists-p doc-exists-p)));
(cons (multiple-value-bind (doc doc-exists-p) (get-all-values key iter-doc)
(setf iter-doc doc exists-p doc-exists-p)))
(t (setf exists-p nil))))
+
(values iter-doc exists-p)))
(defmethod get-element ( (key string) (document document) )
@@ -203,6 +205,7 @@ the document was generated by the client (as opposed to having been read from th
(format stream "~A~%" str)))
+
(defun ht->document (ht)
"Convert a hash-table to a document."
(multiple-value-bind (oid oid-supplied) (gethash "_id" ht)
View
@@ -36,7 +36,7 @@ Mongo allows for execution of java-script on the server side, which provides
an alternative. Typical use would be (rm (iter (db.find 'foo' (kv 'key' 1)))),
which deletes all documents in foo, with field key equal to 1."
(labels ((server-count()
- (get-element "n" (car (docs (db.count collection :all :mongo mongo)))))
+ (get-element "n" (car (docs (db.count collection query :mongo mongo)))))
(delete-docs ()
(db.delete collection (docs (iter (db.find collection query :selector "_id" :mongo mongo :limit 0))) :mongo mongo)))
(do ((line (server-count)

0 comments on commit 90cfd35

Please sign in to comment.