Skip to content

Commit

Permalink
chore: updated readme regarding mongodb_ecto, fixed some specs
Browse files Browse the repository at this point in the history
  • Loading branch information
zookzook committed Feb 10, 2024
1 parent 0ef1482 commit 9d13924
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@
- support for streaming protocol ([See](https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-monitoring.rst#streaming-protocol))
- support for migration scripts

## mongodb_ecto

The version 1.4.0 supports the [mongodb_ecto](https://github.com/elixir-mongo/mongodb_ecto) package.
A series of changes are required to support the adapter. Some BSON encoders and a missing generic update function were added for the adapter.
Most notably, the `find-then-modify` command functions `find_one_and_update` and `find_one_and_replace` now return appropriate
`FindAndModifyResult` structs that contain additional write information otherwise neglected, which the adapter requires.

After upgrading the driver to version 1.4.0 you need to change the code regarding the results of
* `Mongo.find_one_and_update`
* `Mongo.find_one_and_replace`

## Usage

### Installation
Expand All @@ -38,7 +49,7 @@ Add `mongodb_driver` to your mix.exs `deps`.

```elixir
defp deps do
[{:mongodb_driver, "~> 1.0.0"}]
[{:mongodb_driver, "~> 1.4.0"}]
end
```

Expand Down
4 changes: 2 additions & 2 deletions lib/mongo.ex
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ defmodule Mongo do
BSON.document(),
BSON.document(),
Keyword.t()
) :: result(BSON.document()) | {:ok, nil}
) :: result(Mongo.FindAndModifyResult.t()) | {:ok, nil}
def find_one_and_update(topology_pid, coll, filter, update, opts \\ []) do
_ = modifier_docs(update, :update)

Expand Down Expand Up @@ -537,7 +537,7 @@ defmodule Mongo do
BSON.document(),
BSON.document(),
Keyword.t()
) :: result(BSON.document())
) :: result(Mongo.FindAndModifyResult.t())
def find_one_and_replace(topology_pid, coll, filter, replacement, opts \\ []) do
_ = modifier_docs(replacement, :replace)

Expand Down

0 comments on commit 9d13924

Please sign in to comment.