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
* setup instructions; id types
* remove applications: advice
It should be auto-inferred, and if not, extra_applications is correct instead: https://elixirforum.com/t/why-do-we-use-application-function-in-mix-exs/23834/2
* autogenerate: refer to module docs instead
* ecto_repos config example
* add link to full docs
* update versions
Copy file name to clipboardExpand all lines: CHANGELOG.md
+35-30
Original file line number
Diff line number
Diff line change
@@ -7,68 +7,73 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
8
8
## 2.0.0
9
9
10
-
* Change underlying driver from [`mongodb`](https://github.com/elixir-mongo/mongodb) to [`mongodb_driver`](https://github.com/zookzook/elixir-mongodb-driver) 1.4.0
11
-
* Remove config options `pool`, `pool_overflow`, and `pool_timeout`
12
-
* Add support for MongoDB 6.0 and 7.0
13
-
* Add support for loading & dumping nil binaries and dumping nil dates
10
+
- Change underlying driver from [`mongodb`](https://github.com/elixir-mongo/mongodb) to [`mongodb_driver`](https://github.com/zookzook/elixir-mongodb-driver) 1.4
11
+
- Remove config options `pool`, `pool_overflow`, and `pool_timeout`
12
+
- Add support for MongoDB 6.0 and 7.0
13
+
- Add support for loading & dumping nil binaries and dumping nil dates
14
14
15
15
### Possible breaking changes
16
16
17
17
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.
18
18
19
19
## 1.1.2
20
-
* Add support for loading nil dates
20
+
21
+
- Add support for loading nil dates
21
22
22
23
## 1.1.1
23
-
* Allow `binary_id` fields to be nil
24
+
25
+
- Allow `binary_id` fields to be nil
24
26
25
27
## 1.1.0
26
-
* Add support for Ecto 1.11
28
+
29
+
- Add support for Ecto 1.11
27
30
28
31
## 1.0.0
29
32
30
-
* Introduce support for Ecto 3
31
-
* Introduce GitHub actions, replacing Travis CI
32
-
* Use MongoDB 1.0.0 to add support for Mongodb 4.4. and 5.0
33
+
- Introduce support for Ecto 3
34
+
- Introduce GitHub actions, replacing Travis CI
35
+
- Use MongoDB 1.0.0 to add support for Mongodb 4.4. and 5.0
33
36
34
-
* NOTE: This might work with versions of Ecto less than 3.6.
35
-
Refer to the ecto-3 branch if you need to find a commit that works with a non-officially supported version
36
-
of Ecto.
37
+
- NOTE: This might work with versions of Ecto less than 3.6.
38
+
Refer to the ecto-3 branch if you need to find a commit that works with a non-officially supported version
39
+
of Ecto.
37
40
38
41
### Possible breaking changes
39
42
40
-
* Some upsert operations are only supported with MongoDBs 4.2 or newer.
43
+
- Some upsert operations are only supported with MongoDBs 4.2 or newer.
41
44
42
45
## v0.1.4 (2016-03-03)
43
46
44
-
* Support MongoDB version 3.2
47
+
- Support MongoDB version 3.2
45
48
46
49
## v0.1.3 (2016-01-15)
47
50
48
-
* This version is limited to Ecto 1.0 because of known issues with 1.1
51
+
- This version is limited to Ecto 1.0 because of known issues with 1.1
49
52
50
-
* Additions:
51
-
* Implement `count(field, :distinct)`
53
+
- Additions:
52
54
53
-
* Bug fixes:
54
-
* Handle models without autogenerated primary key on update and delete
55
-
* Implement `Ecto.Adapter.stop/2` callback
56
-
* Move encoding to adapter `load` and `dump` callbacks
55
+
- Implement `count(field, :distinct)`
56
+
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
57
61
58
62
## v0.1.2 (2015-10-18)
59
63
60
-
* Breaking changes:
61
-
* Raise on `limit` and `offset` in `update_all` and `delete_all` queries,
62
-
it's not supported by MongoDB, we were failing siletnly before
64
+
- Breaking changes:
65
+
66
+
- Raise on `limit` and `offset` in `update_all` and `delete_all` queries,
67
+
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
@@ -60,19 +76,11 @@ Add `:mongodb_ecto` as a dependency in your `mix.exs` file.
60
76
```elixir
61
77
defdepsdo
62
78
[
63
-
{:mongodb_ecto, "~> 1.0.0"}
79
+
{:mongodb_ecto, "~> 2.0.0"}
64
80
]
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