diff --git a/src/bson-decode.lisp b/src/bson-decode.lisp index 55825b1..0e75c49 100644 --- a/src/bson-decode.lisp +++ b/src/bson-decode.lisp @@ -60,7 +60,7 @@ (size (if (eql type #x02) (octet-to-int32.1 array (+ pos 5)) (octet-to-int32.1 array pos))) - (offset (if (eql type #x02) 9 5)) + (offset (+ pos (if (eql type #x02) 9 5))) (binary (bson-binary type (subseq array offset (+ offset size))))) (setf (gethash key ht) binary) (incf pos totalsize))) diff --git a/src/bson.lisp b/src/bson.lisp index 1bb64f6..719c45a 100644 --- a/src/bson.lisp +++ b/src/bson.lisp @@ -83,7 +83,7 @@ (add-octets (byte-to-octet (type-id value)) array) (add-octets (int32-to-octet (length (data value))) array) (add-octets (data value) array))) - (bson-encode key value :array array :type type :encoder #'encode-value)))) + (call-next-method key value :array array :type type :encoder #'encode-value)))) ; ; The array type is the parent class of other types like string. So see if a type and encoder is diff --git a/src/db.lisp b/src/db.lisp index f76fabd..eb854e1 100644 --- a/src/db.lisp +++ b/src/db.lisp @@ -278,7 +278,8 @@ Create an index specified by the keys in a collection (kv (kv "ns" (full-collection-name mongo collection)) (kv "key" (force-float index)) (spec-gen unique drop-duplicates) - (kv "name" (keys->name (ht->list index)))))))) + (kv "name" (keys->name (ht->list index)))) + :mongo mongo)))) (defmethod db.ensure-index ((collection string) (index kv-container) &key (mongo (mongo)) (unique nil) (drop-duplicates nil)) diff --git a/src/shell.lisp b/src/shell.lisp index 051cbcd..d0ccb36 100644 --- a/src/shell.lisp +++ b/src/shell.lisp @@ -4,10 +4,10 @@ shell commands |# -(defun docs (result) +(defun docs (result &key (mongo (mongo))) "Stop the iterator (if any) and return the list of documents returned by the query. -Typical ue would be in conjunction with db.find like so (docs (iter (db.find 'foo' 'll)))" - (cadr (db.stop result))) +Typical use would be in conjunction with db.find like so (docs (iter (db.find 'foo' 'll)))" + (cadr (db.stop result :mongo mongo))) (defun iter (result &key (mongo (mongo)) (max-per-call 0)) "Exhaustively iterate through a query. The maximum number of responses