Skip to content

Commit 3660092

Browse files
committed
docs: fix links in 4.x docs
Fix #6081
1 parent 6d2963c commit 3660092

10 files changed

+66
-66
lines changed

docs/connections.jade

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ block content
4949
}, 60000);
5050

5151
:markdown
52-
To disable buffering, turn off the [`bufferCommands` option on your schema](http://mongoosejs.com/docs/guide.html#bufferCommands).
52+
To disable buffering, turn off the [`bufferCommands` option on your schema](./guide.html#bufferCommands).
5353
If you have `bufferCommands` on and your connection is hanging, try turning
5454
`bufferCommands` off to see if you haven't opened a connection properly.
5555

@@ -92,7 +92,7 @@ block content
9292

9393
h3#callback Callback
9494
:markdown
95-
The `connect()` function also accepts a callback parameter and returns a [promise](http://mongoosejs.com/docs/promises.html).
95+
The `connect()` function also accepts a callback parameter and returns a [promise](./promises.html).
9696
:js
9797
mongoose.connect(uri, options, function(error) {
9898
// Check error in initial connection. There is no 2nd param to the callback.

docs/documents.jade

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ block content
2222
});
2323
});
2424
:markdown
25-
You can also use [`.set()`](http://mongoosejs.com/docs/api.html#document_Document-set)
25+
You can also use [`.set()`](./api.html#document_Document-set)
2626
to modify documents. Under the hood, `tank.size = 'large';` becomes `tank.set({ size: 'large' })`.
2727
:js
2828
Tank.findById(id, function (err, tank) {
@@ -51,7 +51,7 @@ block content
5151
});
5252
:markdown
5353
The `findAndUpdate/Remove` static methods all make a change to at most one document, and return it with just one call to the database. There [are](./api.html#model_Model.findByIdAndRemove) [several](./api.html#model_Model.findOneAndUpdate) [variations](./api.html#model_Model.findOneAndRemove) on the [findAndModify](http://www.mongodb.org/display/DOCS/findAndModify+Command) theme. Read the [API](./api.html) docs for more detail.
54-
54+
5555
_Note that `findAndUpdate/Remove` do *not* execute any hooks or validation before making the change in the database. You can use the [`runValidators` option](/docs/validation.html#update-validators) to access a limited subset of document validation. However, if you need hooks and full document validation, first query for the document and then `save()` it._
5656

5757
h3 Validating
@@ -61,7 +61,7 @@ block content
6161
h3 Overwriting
6262
:markdown
6363
You can overwrite an entire document using `.set()`. This is handy if you
64-
want to change what document is being saved in [middleware](http://mongoosejs.com/docs/middleware.html).
64+
want to change what document is being saved in [middleware](./docs/middleware.html).
6565
:js
6666
Tank.findById(id, function (err, tank) {
6767
if (err) return handleError(err);

docs/faq.jade

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ block content
9595
:markdown
9696
**A**. This is a performance optimization. These empty objects are not saved
9797
to the database, nor are they in the result `toObject()`, nor do they show
98-
up in `JSON.stringify()` output unless you turn off the [`minimize` option](http://mongoosejs.com/docs/guide.html#minimize).
98+
up in `JSON.stringify()` output unless you turn off the [`minimize` option](./guide.html#minimize).
9999

100100
The reason for this behavior is that Mongoose's change detection
101101
and getters/setters are based on [`Object.defineProperty()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty).
@@ -104,11 +104,11 @@ block content
104104
mongoose defines properties on the `Model` prototype when the model is compiled.
105105
Because mongoose needs to define getters and setters for `nested.prop`, `nested`
106106
must always be defined as an object on a mongoose document, even if `nested`
107-
is undefined on the underlying [POJO](http://mongoosejs.com/docs/guide.html#minimize).
107+
is undefined on the underlying [POJO](./guide.html#minimize).
108108

109109
hr#arrow-functions
110110
:markdown
111-
**Q**. I'm using an arrow function for a [virtual](http://mongoosejs.com/docs/guide.html#virtuals), getter/setter, or [method](http://mongoosejs.com/docs/guide.html#methods) and the value of `this` is wrong.
111+
**Q**. I'm using an arrow function for a [virtual](./guide.html#virtuals), getter/setter, or [method](./guide.html#methods) and the value of `this` is wrong.
112112

113113
**A**. Arrow functions [handle the `this` keyword much differently than conventional functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions#No_binding_of_this).
114114
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.
@@ -215,7 +215,7 @@ block content
215215
**Q**. All function calls on my models hang, what am I doing wrong?
216216

217217
**A**. By default, mongoose will buffer your function calls until it can
218-
connect to MongoDB. Read the [buffering section of the connection docs](http://mongoosejs.com/docs/connections.html#buffering)
218+
connect to MongoDB. Read the [buffering section of the connection docs](./connections.html#buffering)
219219
for more information.
220220

221221
hr#enable_debugging

docs/guide.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ block content
694694

695695
h4#timestamps option: timestamps
696696
:markdown
697-
If set `timestamps`, mongoose assigns `createdAt` and `updatedAt` fields to your schema, the type assigned is [Date](http://mongoosejs.com/docs/api.html#schema-date-js).
697+
If set `timestamps`, mongoose assigns `createdAt` and `updatedAt` fields to your schema, the type assigned is [Date](./api.html#schema-date-js).
698698

699699
By default, the name of two fields are `createdAt` and `updatedAt`, customize the field name by setting `timestamps.createdAt` and `timestamps.updatedAt`.
700700
:js

docs/middleware.jade

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ block content
2828

2929
Aggregate middleware is for `MyModel.aggregate()`. Aggregate middleware
3030
executes when you call `exec()` on an aggregate object.
31-
In aggregate middleware, `this` refers to the [aggregation object](http://mongoosejs.com/docs/api.html#model_Model.aggregate).
31+
In aggregate middleware, `this` refers to the [aggregation object](./api.html#model_Model.aggregate).
3232

33-
* [aggregate](http://mongoosejs.com/docs/api.html#model_Model.aggregate)
33+
* [aggregate](./api.html#model_Model.aggregate)
3434

3535
Model middleware is supported for the following model functions.
3636
In model middleware functions, `this` refers to the model.

docs/populate.jade

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ block content
214214
populate them using the [Model.populate()](./api.html#model_Model.populate)
215215
method available in **mongoose >= 3.6**. This is what `document#populate()`
216216
and `query#populate()` use to populate documents.
217-
217+
218218
h3#deep-populate Populating across multiple levels
219219
:markdown
220220
Say you have a user schema which keeps track of the user's friends.
@@ -235,7 +235,7 @@ block content
235235
// Get friends of friends - populate the 'friends' array for every friend
236236
populate: { path: 'friends' }
237237
});
238-
238+
239239
h3#cross-db-populate Populating across Databases
240240
:markdown
241241
Let's say you have a schema representing events, and a schema representing
@@ -256,14 +256,14 @@ block content
256256
:js
257257
var db1 = mongoose.createConnection('localhost:27000/db1');
258258
var db2 = mongoose.createConnection('localhost:27001/db2');
259-
259+
260260
var Event = db1.model('Event', eventSchema);
261261
var Conversation = db2.model('Conversation', conversationSchema);
262262
:markdown
263263
In this situation, you will **not** be able to `populate()` normally.
264264
The `conversation` field will always be null, because `populate()` doesn't
265265
know which model to use. However,
266-
[you can specify the model explicitly](http://mongoosejs.com/docs/api.html#model_Model.populate).
266+
[you can specify the model explicitly](./api.html#model_Model.populate).
267267
:js
268268
Event.
269269
find().
@@ -286,9 +286,9 @@ block content
286286
item: { type: ObjectId, refPath: 'connections.kind' }
287287
}]
288288
});
289-
289+
290290
var organizationSchema = new Schema({ name: String, kind: String });
291-
291+
292292
var User = mongoose.model('User', userSchema);
293293
var Organization = mongoose.model('Organization', organizationSchema);
294294
:markdown
@@ -320,17 +320,17 @@ block content
320320
// doc.connections[0].item is a User doc
321321
// doc.connections[1].item is an Organization doc
322322
});
323-
323+
324324
h3#populate-virtuals Populate Virtuals
325325
:markdown
326326
_New in 4.5.0_
327-
327+
328328
So far you've only populated based on the `_id` field. However, that's
329329
sometimes not the right choice.
330330
In particular, [arrays that grow without bound are a MongoDB anti-pattern](https://docs.mongodb.com/manual/tutorial/model-referenced-one-to-many-relationships-between-documents/).
331331
Using mongoose virtuals, you can define more sophisticated relationships
332332
between documents.
333-
333+
334334
:js
335335
var PersonSchema = new Schema({
336336
name: String,
@@ -348,10 +348,10 @@ block content
348348
// an array. `justOne` is false by default.
349349
justOne: false
350350
});
351-
351+
352352
var Person = mongoose.model('Person', PersonSchema);
353353
var Band = mongoose.model('Band', BandSchema);
354-
354+
355355
/**
356356
* Suppose you have 2 bands: "Guns N' Roses" and "Motley Crue"
357357
* And 4 people: "Axl Rose" and "Slash" with "Guns N' Roses", and
@@ -360,24 +360,24 @@ block content
360360
Band.find({}).populate('members').exec(function(error, bands) {
361361
/* `bands.members` is now an array of instances of `Person` */
362362
});
363-
363+
364364
:markdown
365365
Keep in mind that virtuals are _not_ included in `toJSON()` output by
366366
default. If you want populate virtuals to show up when using functions
367367
that rely on `JSON.stringify()`, like Express'
368368
[`res.json()` function](http://expressjs.com/en/4x/api.html#res.json),
369369
set the `virtuals: true` option on your schema's `toJSON` options.
370-
370+
371371
:js
372372
// Set `virtuals: true` so `res.json()` works
373373
var BandSchema = new Schema({
374374
name: String
375375
}, { toJSON: { virtuals: true } });
376-
376+
377377
:markdown
378378
If you're using populate projections, make sure `foreignField` is included
379379
in the projection.
380-
380+
381381
:js
382382
Band.
383383
find({}).

docs/queries.jade

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ block content
2828
})
2929
:markdown
3030
Here we see that the query was executed immediately and the results passed to our callback. All callbacks in Mongoose use the pattern:
31-
`callback(error, result)`. If an error occurs executing the query, the `error` parameter will contain an error document, and `result`
31+
`callback(error, result)`. If an error occurs executing the query, the `error` parameter will contain an error document, and `result`
3232
will be null. If the query is successful, the `error` parameter will be null, and the `result` will be populated with the results of the query.
3333
.important
3434
:markdown
@@ -77,24 +77,24 @@ block content
7777
exec(callback);
7878

7979
:markdown
80-
A full list of [Query helper functions can be found in the API docs](http://mongoosejs.com/docs/api.html#query-js).
80+
A full list of [Query helper functions can be found in the API docs](./api.html#query-js).
8181

8282
h3#setters
8383
:markdown
8484
Setters are not executed by default in 4.x. For example, if you lowercase emails in your schema:
85-
85+
8686
:js
8787
var personSchema = new Schema({
8888
email: {
8989
type: String,
9090
lowercase: true
9191
}
9292
});
93-
93+
9494
:markdown
9595
Mongoose will **not** automatically lowercase the email in your queries, so `Person.find({ email: '[email protected]' })` would return no results.
9696
Use the `runSettersOnQuery` option to turn on this behavior:
97-
97+
9898
:js
9999
var personSchema = new Schema({
100100
email: {

docs/schematypes.jade

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ block content
1717
a(href="./api.html#query-js") queries
1818
| and other general characteristics for 
1919
a(href="./api.html#schema-string-js") Strings
20-
| and
20+
| and
2121
a(href="./api.html#schema-number-js") Numbers
2222
|. Check out their respective API documentation for more detail.
2323
p
@@ -88,7 +88,7 @@ block content
8888
var schema1 = new Schema({
8989
test: String // `test` is a path of type String
9090
});
91-
91+
9292
var schema2 = new Schema({
9393
test: { type: String } // `test` is a path of type string
9494
});
@@ -108,14 +108,14 @@ block content
108108
types.
109109
h5 All Schema Types
110110
:markdown
111-
* `required`: boolean or function, if true adds a [required validator](http://mongoosejs.com/docs/validation.html#built-in-validators) for this property
111+
* `required`: boolean or function, if true adds a [required validator](./validation.html#built-in-validators) for this property
112112
* `default`: Any or function, sets a default value for the path. If the value is a function, the return value of the function is used as the default.
113113
* `select`: boolean, specifies default [projections](https://docs.mongodb.com/manual/tutorial/project-fields-from-query-results/) for queries
114-
* `validate`: function, adds a [validator function](http://mongoosejs.com/docs/validation.html#built-in-validators) for this property
114+
* `validate`: function, adds a [validator function](./validation.html#built-in-validators) for this property
115115
* `get`: function, defines a custom getter for this property using [`Object.defineProperty()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty).
116116
* `set`: function, defines a custom setter for this property using [`Object.defineProperty()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty).
117-
* `alias`: string, mongoose >= 4.10.0 only. Defines a [virtual](http://mongoosejs.com/docs/guide.html#virtuals) with the given name that gets/sets this path.
118-
117+
* `alias`: string, mongoose >= 4.10.0 only. Defines a [virtual](./guide.html#virtuals) with the given name that gets/sets this path.
118+
119119
:js
120120
var numberSchema = new Schema({
121121
integerOnly: {
@@ -125,23 +125,23 @@ block content
125125
alias: 'i'
126126
}
127127
});
128-
128+
129129
var Number = mongoose.model('Number', numberSchema);
130-
130+
131131
var doc = new Number();
132132
doc.integerOnly = 2.001;
133133
doc.integerOnly; // 2
134134
doc.i; // 2
135135
doc.i = 3.001;
136136
doc.integerOnly; // 3
137137
doc.i; // 3
138-
138+
139139
h5 Indexes
140140
p
141141
:markdown
142142
You can also define [MongoDB indexes](https://docs.mongodb.com/manual/indexes/)
143143
using schema type options.
144-
144+
145145
:markdown
146146
* `index`: boolean, whether to define an [index](https://docs.mongodb.com/manual/indexes/) on this property.
147147
* `unique`: boolean, whether to define a [unique index](https://docs.mongodb.com/manual/core/index-unique/) on this property.
@@ -160,14 +160,14 @@ block content
160160
* `lowercase`: boolean, whether to always call `.toLowerCase()` on the value
161161
* `uppercase`: boolean, whether to always call `.toUpperCase()` on the value
162162
* `trim`: boolean, whether to always call `.trim()` on the value
163-
* `match`: RegExp, creates a [validator](http://mongoosejs.com/docs/validation.html) that checks if the value matches the given regular expression
164-
* `enum`: Array, creates a [validator](http://mongoosejs.com/docs/validation.html) that checks if the value is in the given array.
163+
* `match`: RegExp, creates a [validator](./validation.html) that checks if the value matches the given regular expression
164+
* `enum`: Array, creates a [validator](./validation.html) that checks if the value is in the given array.
165165

166166
h5 Number
167167
:markdown
168-
* `min`: Number, creates a [validator](http://mongoosejs.com/docs/validation.html) that checks if the value is greater than or equal to the given minimum.
169-
* `max`: Number, creates a [validator](http://mongoosejs.com/docs/validation.html) that checks if the value is less than or equal to the given maximum.
170-
168+
* `min`: Number, creates a [validator](./validation.html) that checks if the value is greater than or equal to the given minimum.
169+
* `max`: Number, creates a [validator](./validation.html) that checks if the value is less than or equal to the given maximum.
170+
171171
h5 Date
172172
:markdown
173173
* `min`: Date
@@ -195,7 +195,7 @@ block content
195195
var Any = new Schema({ any: Object });
196196
var Any = new Schema({ any: Schema.Types.Mixed });
197197
p
198-
| Since it is a schema-less type, you can change the value to anything else you like, but Mongoose loses the ability to auto detect and save those changes. To "tell" Mongoose that the value of a Mixed type has changed, call the
198+
| Since it is a schema-less type, you can change the value to anything else you like, but Mongoose loses the ability to auto detect and save those changes. To "tell" Mongoose that the value of a Mixed type has changed, call the
199199
code .markModified(path)
200200
| method of the document passing the path to the Mixed type you just changed.
201201
:js
@@ -204,7 +204,7 @@ block content
204204
person.save(); // anything will now get saved
205205
h4#objectids ObjectIds
206206
p
207-
| To specify a type of ObjectId, use
207+
| To specify a type of ObjectId, use
208208
code Schema.Types.ObjectId
209209
| in your declaration.
210210
:js
@@ -214,9 +214,9 @@ block content
214214
// or just Schema.ObjectId for backwards compatibility with v2
215215
h4#arrays Arrays
216216
p
217-
| Provide creation of arrays of
217+
| Provide creation of arrays of
218218
a(href="./api.html#schema_Schema.Types") SchemaTypes
219-
| or
219+
| or
220220
a(href="./subdocs.html") Sub-Documents
221221
|.
222222
:js
@@ -229,9 +229,9 @@ block content
229229
// ... etc
230230
});
231231
p
232-
| Note: specifying an empty array is equivalent to
232+
| Note: specifying an empty array is equivalent to
233233
code Mixed
234-
|. The following all create arrays of
234+
|. The following all create arrays of
235235
code Mixed
236236
|:
237237
:js
@@ -268,18 +268,18 @@ block content
268268
});
269269
h3#customtypes Creating Custom Types
270270
p
271-
| Mongoose can also be extended with custom SchemaTypes. Search the
271+
| Mongoose can also be extended with custom SchemaTypes. Search the
272272
a(href="http://plugins.mongoosejs.com") plugins
273-
| site for compatible types like
273+
| site for compatible types like
274274
a(href="https://github.com/aheckmann/mongoose-long") mongoose-long
275275
| , 
276276
a(href="https://github.com/vkarpov15/mongoose-int32") mongoose-int32
277-
| and
277+
| and
278278
a(href="https://github.com/aheckmann/mongoose-function") other
279-
|
279+
|
280280
a(href="https://github.com/OpenifyIt/mongoose-types") types
281281
|.
282-
282+
283283
h3#path The `schema.path()` Function
284284
:markdown
285285
The `schema.path()` function returns the instantiated schema type for a

0 commit comments

Comments
 (0)