From 9f9e625abc46f3e73436186363a7dc9231741e62 Mon Sep 17 00:00:00 2001 From: George Narroway Date: Thu, 9 Jan 2020 23:56:48 +0800 Subject: [PATCH] readme --- CHANGELOG.md | 7 +++++++ README.md | 21 +++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c08cf91..d4516c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 1daa4b4..3e5171b 100644 --- a/README.md +++ b/README.md @@ -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