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: CONTRIBUTING.md
+8-6Lines changed: 8 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,6 +35,7 @@ If you have a question about Mongoose (not a bug report) please post it to eithe
35
35
- Write typings-tests if you modify the typescript-typings. (tests are in the [test/types](https://github.com/Automattic/mongoose/tree/master/test/types) directory).
36
36
37
37
### Running the tests
38
+
38
39
- Open a terminal and navigate to the root of the project
39
40
- execute `npm install` to install the necessary dependencies
40
41
- execute `npm run mongo` to start a MongoDB instance on port 27017. This step is optional, if you have already a database running on port 27017. To spin up a specific mongo version, you can do it by executing `npm run mongo -- {version}`. E.g. you want to spin up a mongo 4.2.2 server, you execute `npm run mongo -- 4.2.2`
@@ -50,7 +51,7 @@ If you have a question about Mongoose (not a bug report) please post it to eithe
50
51
51
52
To contribute to the [API documentation](http://mongoosejs.com/docs/api.html) just make your changes to the inline documentation of the appropriate [source code](https://github.com/Automattic/mongoose/tree/master/lib) in the master branch and submit a [pull request](https://help.github.com/articles/using-pull-requests/). You might also use the github [Edit](https://github.com/blog/844-forking-with-the-edit-button) button.
52
53
53
-
To contribute to the [guide](http://mongoosejs.com/docs/guide.html) or [quick start](http://mongoosejs.com/docs/index.html) docs, make your changes to the appropriate `.pug` files in the [docs](https://github.com/Automattic/mongoose/tree/master/docs) directory of the master branch and submit a pull request. Again, the [Edit](https://github.com/blog/844-forking-with-the-edit-button) button might work for you here.
54
+
To contribute to the [guide](http://mongoosejs.com/docs/guide.html) or [quick start](http://mongoosejs.com/docs/index.html) docs, make your changes to the appropriate `.pug`/ `.md`files in the [docs](https://github.com/Automattic/mongoose/tree/master/docs) directory of the master branch and submit a pull request. Again, the [Edit](https://github.com/blog/844-forking-with-the-edit-button) button might work for you here.
54
55
55
56
If you'd like to preview your documentation changes, first commit your changes to your local master branch, then execute:
56
57
@@ -59,29 +60,30 @@ If you'd like to preview your documentation changes, first commit your changes t
59
60
60
61
Visit `http://localhost:8089` and you should see the docs with your local changes. Make sure you `npm run docs:clean` before committing, because automated generated files to `docs/*` should **not** be in PRs.
61
62
63
+
#### Documentation Style Guidelines
64
+
65
+
There are some guidelines to keep the style for the documentation consistent:
66
+
67
+
- All links that refer to some other file in the mongoose documentation needs to be relative without a prefix unless required (use `guide.html` over `./guide.html` or `/docs/guide.html`)
68
+
62
69
### Plugins website
63
70
64
71
The [plugins](http://plugins.mongoosejs.io/) site is also an [open source project](https://github.com/vkarpov15/mongooseplugins) that you can get involved with. Feel free to fork and improve it as well!
65
72
66
-
67
73
## Financial contributions
68
74
69
75
We also welcome financial contributions in full transparency on our [open collective](https://opencollective.com/mongoose).
70
76
Anyone can file an expense. If the expense makes sense for the development of the community, it will be "merged" in the ledger of our open collective by the core contributors and the person who filed the expense will be reimbursed.
71
77
72
-
73
78
## Credits
74
79
75
-
76
80
### Contributors
77
81
78
82
Thank you to all the people who have already contributed to mongoose!
Copy file name to clipboardExpand all lines: docs/async-await.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,7 +62,7 @@ async function awaitUpdate() {
62
62
}
63
63
```
64
64
65
-
Note that the specific fulfillment values of different Mongoose methods vary, and may be affected by configuration. Please refer to the [API documentation](./api.html) for information about specific methods.
65
+
Note that the specific fulfillment values of different Mongoose methods vary, and may be affected by configuration. Please refer to the [API documentation](api.html) for information about specific methods.
66
66
67
67
### Async Functions
68
68
@@ -108,7 +108,7 @@ Under the hood, [async/await is syntactic sugar](https://developer.mozilla.org/e
108
108
Due to the surprisingly simple way promises are implemented in JavaScript, the keyword `await` will try to unwrap any object with a property whose key is the string ‘then’ and whose value is a function.
109
109
Such objects belong to a broader class of objects called [thenables](https://masteringjs.io/tutorials/fundamentals/thenable).
110
110
If the thenable being unwrapped is a genuine promise, e.g. an instance of the [Promise constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), we enjoy several guarantees about how the object’s ‘then’ function will behave.
111
-
However, Mongoose provides several static helper methods that return a different class of thenable object called a [Query](./queries.html)--and [Queries are not promises](./queries.html#queries-are-not-promises).
111
+
However, Mongoose provides several static helper methods that return a different class of thenable object called a [Query](queries.html)--and [Queries are not promises](queries.html#queries-are-not-promises).
112
112
Because Queries are also *thenables*, we can interact with a Query using async/await just as we would interact with a genuine promise, with one key difference: observing the fulfillment value of a genuine promise cannot under any circumstances change that value, but trying to re-observe the value of a Query may cause the Query to be re-executed.
113
113
114
114
```javascript
@@ -148,4 +148,4 @@ async function observeQuery() {
148
148
149
149
You are most likely to accidentally re-execute queries in this way when mixing callbacks with async/await.
150
150
This is never necessary and should be avoided.
151
-
If you need a Query to return a fully-fledged promise instead of a thenable, you can use [Query#exec()](./api/query.html#query_Query-exec).
151
+
If you need a Query to return a fully-fledged promise instead of a thenable, you can use [Query#exec()](api/query.html#query_Query-exec).
Copy file name to clipboardExpand all lines: docs/faq.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -119,7 +119,7 @@ console.log(new Model());
119
119
120
120
**A**. This is a performance optimization. These empty objects are not saved
121
121
to the database, nor are they in the result `toObject()`, nor do they show
122
-
up in `JSON.stringify()` output unless you turn off the [`minimize` option](./guide.html#minimize).
122
+
up in `JSON.stringify()` output unless you turn off the [`minimize` option](guide.html#minimize).
123
123
124
124
The reason for this behavior is that Mongoose's change detection
125
125
and getters/setters are based on [`Object.defineProperty()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty).
@@ -128,11 +128,11 @@ the overhead of running `Object.defineProperty()` every time a document is creat
128
128
mongoose defines properties on the `Model` prototype when the model is compiled.
129
129
Because mongoose needs to define getters and setters for `nested.prop`, `nested`
130
130
must always be defined as an object on a mongoose document, even if `nested`
131
-
is undefined on the underlying [POJO](./guide.html#minimize).
131
+
is undefined on the underlying [POJO](guide.html#minimize).
132
132
133
133
<hrid="arrow-functions" />
134
134
135
-
<aclass="anchor"href="#arrow-functions">**Q**</a>. I'm using an arrow function for a [virtual](./guide.html#virtuals), [middleware](./middleware.html), [getter](./api.html#schematype_SchemaType-get)/[setter](./api.html#schematype_SchemaType-set), or [method](./guide.html#methods) and the value of `this` is wrong.
135
+
<aclass="anchor"href="#arrow-functions">**Q**</a>. I'm using an arrow function for a [virtual](guide.html#virtuals), [middleware](middleware.html), [getter](api.html#schematype_SchemaType-get)/[setter](api.html#schematype_SchemaType-set), or [method](guide.html#methods) and the value of `this` is wrong.
136
136
137
137
**A**. Arrow functions [handle the `this` keyword much differently than conventional functions](https://masteringjs.io/tutorials/fundamentals/arrow#why-not-arrow-functions).
138
138
Mongoose getters/setters depend on `this` to give you access to the document that you're writing to, but this functionality does not work with arrow functions. Do **not** use arrow functions for mongoose getters/setters unless do not intend to access the document in the getter/setter.
@@ -225,7 +225,7 @@ new Schema({
225
225
<aclass="anchor"href="#model_functions_hanging">**Q**</a>. All function calls on my models hang, what am I doing wrong?
226
226
227
227
**A**. By default, mongoose will buffer your function calls until it can
228
-
connect to MongoDB. Read the [buffering section of the connection docs](./connections.html#buffering)
228
+
connect to MongoDB. Read the [buffering section of the connection docs](connections.html#buffering)
0 commit comments