You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+36-30
Original file line number
Diff line number
Diff line change
@@ -11,68 +11,74 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
11
11
12
12
## 2.0.0
13
13
14
-
* Change underlying driver from [`mongodb`](https://github.com/elixir-mongo/mongodb) to [`mongodb_driver`](https://github.com/zookzook/elixir-mongodb-driver) 1.4.0
15
-
* Remove config options `pool`, `pool_overflow`, and `pool_timeout`
16
-
* Add support for MongoDB 6.0 and 7.0
17
-
* Add support for loading & dumping nil binaries and dumping nil dates
14
+
- Change underlying driver from [`mongodb`](https://github.com/elixir-mongo/mongodb) to [`mongodb_driver`](https://github.com/zookzook/elixir-mongodb-driver) 1.4
15
+
- Remove config options `pool`, `pool_overflow`, and `pool_timeout`
16
+
- Add support for MongoDB 6.0 and 7.0
17
+
- Add support for loading & dumping nil binaries and dumping nil dates
18
+
- Improve README setup instructions
18
19
19
20
### Possible breaking changes
20
21
21
22
Calls to the Ecto adapter itself should not require any changes. However, if you make direct calls to the `Mongo` driver, you will need to update some of them to account for the `mongodb` -> `mongodb_driver` upgrade. See [Migrating to 2.0](./README.md#migrating-to-20) in the Readme.
22
23
23
24
## 1.1.2
24
-
* Add support for loading nil dates
25
+
26
+
- Add support for loading nil dates
25
27
26
28
## 1.1.1
27
-
* Allow `binary_id` fields to be nil
29
+
30
+
- Allow `binary_id` fields to be nil
28
31
29
32
## 1.1.0
30
-
* Add support for Ecto 1.11
33
+
34
+
- Add support for Ecto 1.11
31
35
32
36
## 1.0.0
33
37
34
-
* Introduce support for Ecto 3
35
-
* Introduce GitHub actions, replacing Travis CI
36
-
* Use MongoDB 1.0.0 to add support for Mongodb 4.4. and 5.0
38
+
- Introduce support for Ecto 3
39
+
- Introduce GitHub actions, replacing Travis CI
40
+
- Use MongoDB 1.0.0 to add support for Mongodb 4.4. and 5.0
37
41
38
-
* NOTE: This might work with versions of Ecto less than 3.6.
39
-
Refer to the ecto-3 branch if you need to find a commit that works with a non-officially supported version
40
-
of Ecto.
42
+
- NOTE: This might work with versions of Ecto less than 3.6.
43
+
Refer to the ecto-3 branch if you need to find a commit that works with a non-officially supported version
44
+
of Ecto.
41
45
42
46
### Possible breaking changes
43
47
44
-
* Some upsert operations are only supported with MongoDBs 4.2 or newer.
48
+
- Some upsert operations are only supported with MongoDBs 4.2 or newer.
45
49
46
50
## v0.1.4 (2016-03-03)
47
51
48
-
* Support MongoDB version 3.2
52
+
- Support MongoDB version 3.2
49
53
50
54
## v0.1.3 (2016-01-15)
51
55
52
-
* This version is limited to Ecto 1.0 because of known issues with 1.1
56
+
- This version is limited to Ecto 1.0 because of known issues with 1.1
53
57
54
-
* Additions:
55
-
* Implement `count(field, :distinct)`
58
+
- Additions:
56
59
57
-
* Bug fixes:
58
-
* Handle models without autogenerated primary key on update and delete
59
-
* Implement `Ecto.Adapter.stop/2` callback
60
-
* Move encoding to adapter `load` and `dump` callbacks
60
+
- Implement `count(field, :distinct)`
61
+
62
+
- Bug fixes:
63
+
- Handle models without autogenerated primary key on update and delete
64
+
- Implement `Ecto.Adapter.stop/2` callback
65
+
- Move encoding to adapter `load` and `dump` callbacks
61
66
62
67
## v0.1.2 (2015-10-18)
63
68
64
-
* Breaking changes:
65
-
* Raise on `limit` and `offset` in `update_all` and `delete_all` queries,
66
-
it's not supported by MongoDB, we were failing siletnly before
69
+
- Breaking changes:
70
+
71
+
- Raise on `limit` and `offset` in `update_all` and `delete_all` queries,
72
+
it's not supported by MongoDB, we were failing siletnly before
# Add Repo to this list so you can run commands like `mix ecto.create`.
32
+
ecto_repos: [Repo]
26
33
27
34
# In your application code
28
35
defmoduleRepodo
29
-
useEcto.Repo, otp_app::my_app
36
+
useEcto.Repo,
37
+
otp_app::my_app,
38
+
adapter:Mongo.Ecto
39
+
40
+
defpool() do
41
+
Ecto.Adapter.lookup_meta(__MODULE__).pid
42
+
end
30
43
end
31
44
32
45
defmoduleWeatherdo
33
-
useEcto.Model
46
+
useEcto.Schema
34
47
48
+
# see Mongo.Ecto module docs for explanation of this line
35
49
@primary_key {:id, :binary_id, autogenerate:true}
50
+
51
+
# weather is the MongoDB collection name
36
52
schema "weather"do
37
53
field :city# Defaults to type :string
38
54
field :temp_lo, :integer
@@ -65,14 +81,6 @@ def deps do
65
81
end
66
82
```
67
83
68
-
You should also update your applications to include both projects:
69
-
70
-
```elixir
71
-
defapplicationdo
72
-
[applications: [:logger, :mongodb_ecto, :ecto]]
73
-
end
74
-
```
75
-
76
84
To use the adapter in your repo:
77
85
78
86
```elixir
@@ -83,7 +91,7 @@ defmodule MyApp.Repo do
83
91
end
84
92
```
85
93
86
-
For additional information on usage please see the documentation for [Ecto](http://hexdocs.pm/ecto).
94
+
For additional information on usage please see the documentation for the [Mongo.Ecto module](https://hexdocs.pm/mongodb_ecto/Mongo.Ecto.html) and for [Ecto](http://hexdocs.pm/ecto).
87
95
88
96
## Data Type Mapping
89
97
@@ -124,27 +132,30 @@ The adapter and the driver are tested against most recent versions from 5.0, 6.0
124
132
125
133
## Migrating to 2.0
126
134
127
-
Release 2.0 changes the underlying driver from [`mongodb`](https://github.com/elixir-mongo/mongodb) to [`mongodb_driver`](https://github.com/zookzook/elixir-mongodb-driver) 1.4.0. Calls to the Ecto adapter itself should not require any changes. Some config options are no longer used and can be simply deleted: `pool`, `pool_overflow`, `pool_timeout`.
135
+
Release 2.0 changes the underlying driver from [`mongodb`](https://github.com/elixir-mongo/mongodb) to [`mongodb_driver`](https://github.com/zookzook/elixir-mongodb-driver) 1.4. Calls to the Ecto adapter itself should not require any changes. Some config options are no longer used and can be simply deleted: `pool`, `pool_overflow`, `pool_timeout`.
136
+
137
+
If you make direct calls to the `Mongo` driver, you will need to update some of them to account for the `mongodb` -> `mongodb_driver` upgrade. Also, remember to replace `:mongodb` with `{:mongodb_driver, "~> 1.4"}` in your `mix.exs`. The known updates are:
128
138
129
-
If you make direct calls to the `Mongo` driver, you will need to update some of them to account for the `mongodb` -> `mongodb_driver` upgrade. Also, remember to replace `:mongodb` with `{:mongodb_driver, "~> 1.4.0"}` in your `mix.exs`. The known updates are:
130
139
1.`Mongo` functions no longer accept a `pool` option or `MyApp.Repo.Pool` module argument. Instead, a pool PID is expected:
# Provided the following function is defined in MyApp.Repo:
150
+
defmoduleMyApp.Repodo
151
+
useEcto.Repo, otp_app::my_app, adapter:Mongo.Ecto
152
+
153
+
defpool() do
154
+
Ecto.Adapter.lookup_meta(__MODULE__).pid
155
+
end
156
+
end
157
+
```
158
+
148
159
2.[`Mongo.command`](https://hexdocs.pm/mongodb_driver/1.4.1/Mongo.html#command/3) requires a keyword list instead of a document. E.g., instead of `Mongo.command(MyApp.Repo.pool(), %{listCollections: 1}, opts)`, do `Mongo.command(MyApp.Repo.pool(), [listCollections: 1], opts)`.
149
160
3.`Mongo.ReadPreferences.defaults` is renamed to `Mongo.ReadPreference.merge_defaults`.
150
161
4. When passing a `hint` to `Mongo.find_one` etc., if the hinted index does not exist, an error is now returned.
Copy file name to clipboardExpand all lines: lib/mongo_ecto.ex
+7-1
Original file line number
Diff line number
Diff line change
@@ -28,6 +28,12 @@ defmodule Mongo.Ecto do
28
28
password: "mongodb",
29
29
hostname: "localhost"
30
30
31
+
config :my_app,
32
+
# Add Repo to this list so you can run commands like `mix ecto.create`.
33
+
ecto_repos: [Repo]
34
+
35
+
For more connection options, see mongodb-driver's [Mongo.start_link](https://hexdocs.pm/mongodb_driver/1.5.2/Mongo.html#start_link/1). Note that to use a connection string (mongodb:// or mongodb+srv://), you must set `mongo_url: ` instead of `url: `.
36
+
31
37
Each repository in Ecto defines a `start_link/0` function that needs to be
32
38
invoked before using the repository. This function is generally from your
0 commit comments