Skip to content

Commit

Permalink
Implement ensure-index properly
Browse files Browse the repository at this point in the history
  • Loading branch information
naryl committed Sep 26, 2013
1 parent 62cbe38 commit c318145
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions driver/collection.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
(defclass collection ()
((database :initarg :database :reader collection-database)
(name :initarg :name :reader collection-name)
(indexes :initform nil :accessor collection-indexes)
(fullname :reader fullname)))

(defun collection (database name)
Expand Down
8 changes: 6 additions & 2 deletions driver/indexes.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@
(setf (gethash "key" index) keys
(gethash "ns" index) (fullname collection)
(gethash "name" index) (gethash "name" index name))
(pushnew name (collection-indexes collection) :test #'equal)
(insert-op index-collection index)))

(defun ensure-index (collection keys &optional (options (son)))
;; Should be cached
(create-index collection keys options))
(unless (find (make-name keys)
(collection-indexes collection)
:test #'equal)
(create-index collection keys options)))

(defun drop-indexes (collection &optional (name "*"))
(setf (collection-indexes collection) nil)
(let ((cmd (son "dropIndexes" (collection-name collection)
"index" name)))
(maybe-finished
Expand Down

0 comments on commit c318145

Please sign in to comment.