This commit is contained in:
George Narroway 2020-01-09 23:56:48 +08:00
parent e7c18692a1
commit 9f9e625abc
2 changed files with 28 additions and 0 deletions

View file

@ -1,6 +1,13 @@
# Change Log
All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/).
## 0.6.0-SNAPSHOT
### Added
- Support for bulk-write
### Changed
- Moved option creators and document conversion to the `mongo-driver-3.model` namespace (breaking change)
## 0.5.0 - 2019-11-22
### Added
- Support for transactions

View file

@ -135,6 +135,27 @@ Many mongo queries take operators like `$eq` and `$gt`. These are exposed in the
(mc/find db "test" {:a {"$gt" 3}})
```
### Bulk operations
The bulk API is similar to the [mongo shell](https://docs.mongodb.com/manual/reference/method/db.collection.bulkWrite/),
except each operation is defined as a 2-tuple rather than a map.
```clojure
;; Execute a mix of operations in one go
(bulk-write [[:insert-one {:document {:a 1}}]
[:delete-one {:filter {:a 1}}]
[:delete-many {:filter {:a 1}}]
[:update-one {:filter {:a 1} :update {:$set {:a 2}}}]
[:update-many {:filter {:a 1} :update {:$set {:a 2}}}]
[:replace-one {:filter {:a 1} :replacement {:a 2}}]])
; => a BulkWriteResult
;; Each operation can take the same options as their respective functions
(bulk-write [[:update-one {:filter {:a 1} :update {:$set {:a 2}} :upsert? true}]
[:update-many {:filter {:a 1} :update {:$set {:a 2}} :upsert? true}]
[:replace-one {:filter {:a 1} :replacement {:a 2} :upsert? true}]])
```
### Using transactions
You can create a session to perform multi-document transactions, where all operations either