mongoose 6.7.4 → 6.8.0
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/README.md +27 -6
- package/dist/browser.umd.js +1 -1
- package/lib/aggregate.js +8 -8
- package/lib/browser.js +1 -1
- package/lib/connection.js +2 -1
- package/lib/cursor/AggregationCursor.js +1 -1
- package/lib/cursor/QueryCursor.js +19 -1
- package/lib/document.js +39 -7
- package/lib/drivers/node-mongodb-native/collection.js +6 -1
- package/lib/error/index.js +5 -5
- package/lib/error/validator.js +5 -4
- package/lib/helpers/populate/assignRawDocsToIdStructure.js +0 -1
- package/lib/helpers/populate/getModelsMapForPopulate.js +3 -4
- package/lib/helpers/printStrictQueryWarning.js +11 -0
- package/lib/helpers/schema/merge.js +1 -0
- package/lib/index.js +13 -8
- package/lib/model.js +45 -44
- package/lib/query.js +18 -18
- package/lib/queryhelpers.js +5 -0
- package/lib/schema/string.js +3 -3
- package/lib/schema.js +0 -2
- package/lib/schematype.js +11 -11
- package/lib/types/array/methods/index.js +1 -1
- package/lib/virtualtype.js +1 -1
- package/package.json +16 -15
- package/types/collection.d.ts +0 -2
- package/types/cursor.d.ts +7 -0
- package/types/document.d.ts +1 -1
- package/types/index.d.ts +16 -8
- package/types/inferschematype.d.ts +35 -26
- package/types/middlewares.d.ts +18 -1
- package/types/models.d.ts +12 -4
- package/types/populate.d.ts +33 -29
- package/types/query.d.ts +1 -1
- package/types/schemaoptions.d.ts +10 -2
- package/types/schematypes.d.ts +4 -4
- package/types/types.d.ts +1 -1
- package/types/utility.d.ts +1 -0
package/README.md
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
# Mongoose
|
|
2
2
|
|
|
3
|
-
Mongoose is a [MongoDB](https://www.mongodb.org/) object modeling tool designed to work in an asynchronous environment. Mongoose supports
|
|
3
|
+
Mongoose is a [MongoDB](https://www.mongodb.org/) object modeling tool designed to work in an asynchronous environment. Mongoose supports [Node.js](https://nodejs.org/en/) and [Deno](https://deno.land/) (alpha).
|
|
4
4
|
|
|
5
|
-
[](https://mongoosejsteam.slack.com)
|
|
6
5
|
[](https://github.com/Automattic/mongoose)
|
|
7
6
|
[](http://badge.fury.io/js/mongoose)
|
|
7
|
+
[](https://deno.land/x/mongoose)
|
|
8
|
+
[](https://deno.land/x/mongoose)
|
|
8
9
|
|
|
9
10
|
[](https://www.npmjs.com/package/mongoose)
|
|
10
11
|
|
|
@@ -45,6 +46,8 @@ First install [Node.js](http://nodejs.org/) and [MongoDB](https://www.mongodb.or
|
|
|
45
46
|
$ npm install mongoose
|
|
46
47
|
```
|
|
47
48
|
|
|
49
|
+
Mongoose 6.8.0 also includes alpha support for [Deno](https://deno.land/).
|
|
50
|
+
|
|
48
51
|
## Importing
|
|
49
52
|
|
|
50
53
|
```javascript
|
|
@@ -55,6 +58,24 @@ const mongoose = require('mongoose');
|
|
|
55
58
|
import mongoose from 'mongoose';
|
|
56
59
|
```
|
|
57
60
|
|
|
61
|
+
Or, using [Deno's `createRequire()` for CommonJS support](https://deno.land/std@0.113.0/node/README.md?source=#commonjs-modules-loading) as follows.
|
|
62
|
+
|
|
63
|
+
```javascript
|
|
64
|
+
import { createRequire } from "https://deno.land/std/node/module.ts";
|
|
65
|
+
const require = createRequire(import.meta.url);
|
|
66
|
+
|
|
67
|
+
const mongoose = require('mongoose');
|
|
68
|
+
|
|
69
|
+
mongoose.connect('mongodb://localhost:27017/test')
|
|
70
|
+
.then(() => console.log('Connected!'));
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
You can then run the above script using the following.
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
deno run --allow-net --allow-read --allow-sys --allow-env mongoose-test.js
|
|
77
|
+
```
|
|
78
|
+
|
|
58
79
|
## Mongoose for Enterprise
|
|
59
80
|
|
|
60
81
|
Available as part of the Tidelift Subscription
|
|
@@ -98,9 +119,9 @@ const BlogPost = new Schema({
|
|
|
98
119
|
Aside from defining the structure of your documents and the types of data you're storing, a Schema handles the definition of:
|
|
99
120
|
|
|
100
121
|
* [Validators](http://mongoosejs.com/docs/validation.html) (async and sync)
|
|
101
|
-
* [Defaults](http://mongoosejs.com/docs/api.html#schematype_SchemaType-default)
|
|
102
|
-
* [Getters](http://mongoosejs.com/docs/api.html#schematype_SchemaType-get)
|
|
103
|
-
* [Setters](http://mongoosejs.com/docs/api.html#schematype_SchemaType-set)
|
|
122
|
+
* [Defaults](http://mongoosejs.com/docs/api/schematype.html#schematype_SchemaType-default)
|
|
123
|
+
* [Getters](http://mongoosejs.com/docs/api/schematype.html#schematype_SchemaType-get)
|
|
124
|
+
* [Setters](http://mongoosejs.com/docs/api/schematype.html#schematype_SchemaType-set)
|
|
104
125
|
* [Indexes](http://mongoosejs.com/docs/guide.html#indexes)
|
|
105
126
|
* [Middleware](http://mongoosejs.com/docs/middleware.html)
|
|
106
127
|
* [Methods](http://mongoosejs.com/docs/guide.html#methods) definition
|
|
@@ -316,7 +337,7 @@ return a cursor.
|
|
|
316
337
|
|
|
317
338
|
## API Docs
|
|
318
339
|
|
|
319
|
-
Find the API docs [here](http://mongoosejs.com/docs/api.html), generated using [dox](https://github.com/tj/dox)
|
|
340
|
+
Find the API docs [here](http://mongoosejs.com/docs/api/mongoose.html), generated using [dox](https://github.com/tj/dox)
|
|
320
341
|
and [acquit](https://github.com/vkarpov15/acquit).
|
|
321
342
|
|
|
322
343
|
## Related Projects
|