From 75070059d393e71da64559ab582404c9cb9520b1 Mon Sep 17 00:00:00 2001 From: Mariano Montone Date: Tue, 10 Mar 2015 17:14:57 -0300 Subject: [PATCH 1/4] Package nickname --- src/packages.lisp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/packages.lisp b/src/packages.lisp index 82ade25..bcba92d 100644 --- a/src/packages.lisp +++ b/src/packages.lisp @@ -2,6 +2,7 @@ (defpackage #:cl-mongo (:use #:common-lisp #:babel #:uuid #:usocket) + (:nicknames #:mongo) (:export ;; @@ -39,7 +40,7 @@ :db.iter :db.iterator :db.stop - :db.delete + :db.delete :db.ensure-index :db.run-command :db.indexes From 8845f0ee00d0492085ba8715bee0cef3e8badb88 Mon Sep 17 00:00:00 2001 From: Mariano Montone Date: Tue, 10 Mar 2015 17:46:19 -0300 Subject: [PATCH 2/4] Drop collection command --- src/packages.lisp | 1 + src/shell.lisp | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/packages.lisp b/src/packages.lisp index bcba92d..004d75f 100644 --- a/src/packages.lisp +++ b/src/packages.lisp @@ -28,6 +28,7 @@ :mongo-swap :with-mongo-connection :kv + :drop :db.create-collection :db.use diff --git a/src/shell.lisp b/src/shell.lisp index 051cbcd..b39123c 100644 --- a/src/shell.lisp +++ b/src/shell.lisp @@ -44,6 +44,9 @@ which deletes all documents in foo, with field key equal to 1." ((zerop line)) (delete-docs)))) +(defun drop (collection &key (mongo (mongo))) + (db.run-command "drop" :arg collection)) + (defvar *indent*) (defun new-line (stream) From 1fa1f0d85c4d5bca163eb210c066b9dece20814c Mon Sep 17 00:00:00 2001 From: Mariano Montone Date: Fri, 13 Mar 2015 12:17:51 -0300 Subject: [PATCH 3/4] $and and $or operators --- src/mongo-syntax.lisp | 15 +++++++++++++++ src/packages.lisp | 2 ++ 2 files changed, 17 insertions(+) diff --git a/src/mongo-syntax.lisp b/src/mongo-syntax.lisp index c1978f0..2be447d 100644 --- a/src/mongo-syntax.lisp +++ b/src/mongo-syntax.lisp @@ -99,6 +99,21 @@ (defmacro $size (&rest args) `($op "$size" ,@args)) +(defmacro $or (&rest args) + (let ((size (length args)) + (arr (gensym))) + `(let ((,arr (make-bson-array :size ,size))) + ,@(loop for arg in args + collect `(bson-array-push ,arg ,arr)) + (kv "$or" ,arr)))) + +(defmacro $and (&rest args) + (let ((size (length args)) + (arr (gensym))) + `(let ((,arr (make-bson-array :size ,size))) + ,@(loop for arg in args + collect `(bson-array-push ,arg ,arr)) + (kv "$and" ,arr)))) (defun empty-str(str) (if (and str (zerop (length str))) diff --git a/src/packages.lisp b/src/packages.lisp index 004d75f..3ee7363 100644 --- a/src/packages.lisp +++ b/src/packages.lisp @@ -83,6 +83,8 @@ :$exists :$/ :$not + :$and + :$or :$em :$where :$index From 373e9083911c854fcad158bbdfabfbb33c52fdad Mon Sep 17 00:00:00 2001 From: Mariano Montone Date: Sun, 24 Jan 2016 17:42:58 -0300 Subject: [PATCH 4/4] Indentation --- src/db.lisp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/db.lisp b/src/db.lisp index f76fabd..f87c8ec 100644 --- a/src/db.lisp +++ b/src/db.lisp @@ -333,7 +333,9 @@ For most commands you can just uses the key-value shown in the mongo documentati (assert (not (null collection))) (db.find "$cmd" (kv (kv "dropIndexes" collection) (kv "index" index)) :mongo mongo)) -(defmethod db.run-command ((cmd (eql :drop)) &key (mongo (mongo)) (collection nil) (index "*")) +(defmethod db.run-command ((cmd (eql :drop)) &key (mongo (mongo)) + (collection nil) + (index "*")) (assert (not (null collection))) (db.find "$cmd" (kv->ht (kv "drop" collection)) :mongo mongo))