mongoose 7.3.1 → 7.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +3 -1
- package/.markdownlint-cli2.cjs +69 -0
- package/README.md +24 -25
- package/dist/browser.umd.js +1 -1
- package/lib/connection.js +1 -2
- package/lib/cursor/QueryCursor.js +22 -14
- package/lib/index.js +2 -4
- package/lib/model.js +19 -14
- package/lib/query.js +21 -1
- package/package.json +16 -15
- package/types/index.d.ts +3 -1
package/.eslintrc.js
CHANGED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// this file is named ".cjs" instead of ".js" because markdownlint-cli2 only looks for ".cjs" or ".mjs"
|
|
3
|
+
|
|
4
|
+
// use aliases instead of "MD000" naming
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
ignores: [
|
|
8
|
+
// the following are ignored because they are just redirects
|
|
9
|
+
'History.md',
|
|
10
|
+
'SECURITY.md',
|
|
11
|
+
'migrating_to_5.md', // this does not affect "docs/migrating_to_5.md"
|
|
12
|
+
|
|
13
|
+
// ignored for now, but should be changes later
|
|
14
|
+
'.github/PULL_REQUEST_TEMPLATE.md',
|
|
15
|
+
|
|
16
|
+
// ignore changelog because it uses different heading style than other documents and older versions use different formatting
|
|
17
|
+
'CHANGELOG.md',
|
|
18
|
+
|
|
19
|
+
// exclude node_modules because it isnt excluded by default
|
|
20
|
+
'node_modules'
|
|
21
|
+
]
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
module.exports.config = {
|
|
25
|
+
// disable default rules
|
|
26
|
+
default: false,
|
|
27
|
+
|
|
28
|
+
// alt-text for images
|
|
29
|
+
accessibility: true,
|
|
30
|
+
// consistent blank lines
|
|
31
|
+
blank_lines: true,
|
|
32
|
+
// consistent unordered lists
|
|
33
|
+
bullet: { style: 'asterisk' },
|
|
34
|
+
// consistent and read-able code
|
|
35
|
+
code: true,
|
|
36
|
+
// consistent emphasis characters
|
|
37
|
+
emphasis: { style: 'asterisk' },
|
|
38
|
+
// ensure consistent header usage
|
|
39
|
+
headers: { style: 'atx' },
|
|
40
|
+
// ensure consistent "hr" usage
|
|
41
|
+
hr: { style: '---' },
|
|
42
|
+
// disable disalloing html tags, because
|
|
43
|
+
// mongoose currently uses html tags directly for heading ID's and style
|
|
44
|
+
html: false,
|
|
45
|
+
// consistent indentation
|
|
46
|
+
indentation: true,
|
|
47
|
+
// consistent links and good links
|
|
48
|
+
links: true,
|
|
49
|
+
// enabled by "links"
|
|
50
|
+
// mongoose currently does not wrap plain links in "<>"
|
|
51
|
+
'no-bare-urls': false,
|
|
52
|
+
// consistent ordered lists
|
|
53
|
+
ol: true,
|
|
54
|
+
// consistent whitespace usage
|
|
55
|
+
whitespace: true
|
|
56
|
+
|
|
57
|
+
// atx: undefined, // covered by "headers"
|
|
58
|
+
// atx_closed: undefined, // covered by "headers"
|
|
59
|
+
// blockquote: true, // covered by "whitespace"
|
|
60
|
+
// hard_tab: undefined, // covered by "whitespace"
|
|
61
|
+
// headings: undefined, // covered by "headers"
|
|
62
|
+
// images: true, // covered by "accessibility" and "links"
|
|
63
|
+
// language: undefined, // covered by "code"
|
|
64
|
+
// line_length: undefined, // mongoose currently uses a mix of max-line-length and relying on editor auto-wrap
|
|
65
|
+
// spaces: undefined, // covered by "atx", "atx_closed", "headers"
|
|
66
|
+
// spelling: undefined, // mongoose currently only uses short-form language specifiers and so does not need this
|
|
67
|
+
// ul: undefined, // covered by "whitespace" and "bullet"
|
|
68
|
+
// url: undefined, // covered by "links"
|
|
69
|
+
};
|
package/README.md
CHANGED
|
@@ -17,11 +17,11 @@ Mongoose 7.0.0 was released on February 27, 2023. You can find more details on [
|
|
|
17
17
|
|
|
18
18
|
## Support
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
* [Stack Overflow](http://stackoverflow.com/questions/tagged/mongoose)
|
|
21
|
+
* [Bug Reports](https://github.com/Automattic/mongoose/issues/)
|
|
22
|
+
* [Mongoose Slack Channel](http://slack.mongoosejs.io/)
|
|
23
|
+
* [Help Forum](http://groups.google.com/group/mongoose-orm)
|
|
24
|
+
* [MongoDB Support](https://www.mongodb.com/docs/manual/support/)
|
|
25
25
|
|
|
26
26
|
## Plugins
|
|
27
27
|
|
|
@@ -43,7 +43,7 @@ View all 400+ [contributors](https://github.com/Automattic/mongoose/graphs/contr
|
|
|
43
43
|
First install [Node.js](http://nodejs.org/) and [MongoDB](https://www.mongodb.org/downloads). Then:
|
|
44
44
|
|
|
45
45
|
```sh
|
|
46
|
-
|
|
46
|
+
npm install mongoose
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
Mongoose 6.8.0 also includes alpha support for [Deno](https://deno.land/).
|
|
@@ -72,7 +72,7 @@ mongoose.connect('mongodb://127.0.0.1:27017/test')
|
|
|
72
72
|
|
|
73
73
|
You can then run the above script using the following.
|
|
74
74
|
|
|
75
|
-
```
|
|
75
|
+
```sh
|
|
76
76
|
deno run --allow-net --allow-read --allow-sys --allow-env mongoose-test.js
|
|
77
77
|
```
|
|
78
78
|
|
|
@@ -96,7 +96,7 @@ await mongoose.connect('mongodb://127.0.0.1/my_database');
|
|
|
96
96
|
|
|
97
97
|
Once connected, the `open` event is fired on the `Connection` instance. If you're using `mongoose.connect`, the `Connection` is `mongoose.connection`. Otherwise, `mongoose.createConnection` return value is a `Connection`.
|
|
98
98
|
|
|
99
|
-
**Note:**
|
|
99
|
+
**Note:** *If the local connection fails then try using 127.0.0.1 instead of localhost. Sometimes issues may arise when the local hostname has been changed.*
|
|
100
100
|
|
|
101
101
|
**Important!** Mongoose buffers all the commands until it's connected to the database. This means that you don't have to wait until it connects to MongoDB in order to define models, run queries, etc.
|
|
102
102
|
|
|
@@ -168,13 +168,13 @@ Or just do it all at once
|
|
|
168
168
|
const MyModel = mongoose.model('ModelName', mySchema);
|
|
169
169
|
```
|
|
170
170
|
|
|
171
|
-
The first argument is the
|
|
171
|
+
The first argument is the *singular* name of the collection your model is for. **Mongoose automatically looks for the *plural* version of your model name.** For example, if you use
|
|
172
172
|
|
|
173
173
|
```js
|
|
174
174
|
const MyModel = mongoose.model('Ticket', mySchema);
|
|
175
175
|
```
|
|
176
176
|
|
|
177
|
-
Then `MyModel` will use the
|
|
177
|
+
Then `MyModel` will use the **tickets** collection, not the **ticket** collection. For more details read the [model docs](https://mongoosejs.com/docs/api/mongoose.html#mongoose_Mongoose-model).
|
|
178
178
|
|
|
179
179
|
Once we have our model, we can then instantiate it, and save it:
|
|
180
180
|
|
|
@@ -221,7 +221,7 @@ await m.save(); // does not work b/c the default connection object was never con
|
|
|
221
221
|
|
|
222
222
|
In the first example snippet, we defined a key in the Schema that looks like:
|
|
223
223
|
|
|
224
|
-
```
|
|
224
|
+
```txt
|
|
225
225
|
comments: [Comment]
|
|
226
226
|
```
|
|
227
227
|
|
|
@@ -250,7 +250,6 @@ await post.save();
|
|
|
250
250
|
|
|
251
251
|
Embedded documents enjoy all the same features as your models. Defaults, validators, middleware.
|
|
252
252
|
|
|
253
|
-
|
|
254
253
|
### Middleware
|
|
255
254
|
|
|
256
255
|
See the [docs](http://mongoosejs.com/docs/middleware.html) page.
|
|
@@ -331,26 +330,26 @@ and [acquit](https://github.com/vkarpov15/acquit).
|
|
|
331
330
|
|
|
332
331
|
## Related Projects
|
|
333
332
|
|
|
334
|
-
|
|
333
|
+
### MongoDB Runners
|
|
335
334
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
335
|
+
* [run-rs](https://www.npmjs.com/package/run-rs)
|
|
336
|
+
* [mongodb-memory-server](https://www.npmjs.com/package/mongodb-memory-server)
|
|
337
|
+
* [mongodb-topology-manager](https://www.npmjs.com/package/mongodb-topology-manager)
|
|
339
338
|
|
|
340
|
-
|
|
339
|
+
### Unofficial CLIs
|
|
341
340
|
|
|
342
|
-
|
|
341
|
+
* [mongoosejs-cli](https://www.npmjs.com/package/mongoosejs-cli)
|
|
343
342
|
|
|
344
|
-
|
|
343
|
+
### Data Seeding
|
|
345
344
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
345
|
+
* [dookie](https://www.npmjs.com/package/dookie)
|
|
346
|
+
* [seedgoose](https://www.npmjs.com/package/seedgoose)
|
|
347
|
+
* [mongoose-data-seed](https://www.npmjs.com/package/mongoose-data-seed)
|
|
349
348
|
|
|
350
|
-
|
|
349
|
+
### Express Session Stores
|
|
351
350
|
|
|
352
|
-
|
|
353
|
-
|
|
351
|
+
* [connect-mongodb-session](https://www.npmjs.com/package/connect-mongodb-session)
|
|
352
|
+
* [connect-mongo](https://www.npmjs.com/package/connect-mongo)
|
|
354
353
|
|
|
355
354
|
## License
|
|
356
355
|
|