From cea1b267083e3346eaf3a676bb21815cea83bc9b Mon Sep 17 00:00:00 2001 From: Hafez Date: Fri, 15 May 2020 07:27:48 +0200 Subject: [PATCH 1/2] docs(faq): remove slow-localhost --- docs/faq.pug | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/docs/faq.pug b/docs/faq.pug index 8f64ebf8e60..825199c95b6 100644 --- a/docs/faq.pug +++ b/docs/faq.pug @@ -429,19 +429,6 @@ block content **A**. Technically, any 12 character string is a valid [ObjectId](https://docs.mongodb.com/manual/reference/bson-types/#objectid). Consider using a regex like `/^[a-f0-9]{24}$/` to test whether a string is exactly 24 hex characters. -
- - **Q**. I'm connecting to `localhost` and it takes me nearly 1 second to connect. How do I fix this? - - **A**. The underlying MongoDB driver defaults to looking for IPv6 addresses, so the most likely cause is that your `localhost` DNS mapping isn't configured to handle IPv6. Use `127.0.0.1` instead of `localhost` or use the `family` option as shown in the [connection docs](https://mongoosejs.com/docs/connections.html#options). - - ```javascript - // One alternative is to bypass 'localhost' - mongoose.connect('mongodb://127.0.0.1:27017/test'); - // Another option is to specify the `family` option, which tells the - // MongoDB driver to only look for IPv4 addresses rather than IPv6 first. - mongoose.connect('mongodb://localhost:27017/test', { family: 4 }); - ```
From d0674d9fb5bc35e80dc5271720ed8601007bdefc Mon Sep 17 00:00:00 2001 From: Hafez Date: Fri, 15 May 2020 07:28:09 +0200 Subject: [PATCH 2/2] style: add empty lines before each question --- docs/faq.pug | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/faq.pug b/docs/faq.pug index 825199c95b6..59f08721765 100644 --- a/docs/faq.pug +++ b/docs/faq.pug @@ -30,6 +30,7 @@ block content #native_company# — #native_desc# +
**Q**. Why don't my changes to arrays get saved when I update an element @@ -72,6 +73,7 @@ block content doc.save(); ``` +
**Q**. I declared a schema property as `unique` but I can still save @@ -124,6 +126,7 @@ block content rather than relying on mongoose to do it for you. The `unique` option for schemas is convenient for development and documentation, but mongoose is *not* an index management solution. +
**Q**. When I have a nested property in a schema, mongoose adds empty objects by default. Why? @@ -154,6 +157,7 @@ block content must always be defined as an object on a mongoose document, even if `nested` is undefined on the underlying [POJO](./guide.html#minimize). +
**Q**. When I use named imports like `import { set } from 'mongoose'`, I @@ -179,6 +183,7 @@ block content foo(); // "undefined" ``` +
**Q**. 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. @@ -209,6 +214,7 @@ block content }); ``` +
**Q**. I have an embedded property named `type` like this: @@ -253,6 +259,7 @@ block content }); ``` +
**Q**. I'm populating a nested property under an array like the below code: @@ -278,6 +285,7 @@ block content connect to MongoDB. Read the [buffering section of the connection docs](./connections.html#buffering) for more information. +
**Q**. How can I enable debugging? @@ -294,6 +302,7 @@ block content All executed collection methods will log output of their arguments to your console. +
**Q**. My `save()` callback never executes. What am I doing wrong? @@ -319,6 +328,7 @@ block content mongoose.set('bufferCommands', false); ``` +
**Q**. Should I create/destroy a new connection for each database operation? @@ -326,6 +336,7 @@ block content **A**. No. Open your connection when your application starts up and leave it open until the application shuts down. +
**Q**. Why do I get "OverwriteModelError: Cannot overwrite .. model once @@ -351,6 +362,7 @@ block content var Kitten = connection.model('Kitten', kittySchema); ``` +
**Q**. How can I change mongoose's default behavior of initializing an array @@ -365,6 +377,8 @@ block content } }); ``` + +
**Q**. How can I initialize an array path to `null`? @@ -389,6 +403,7 @@ block content to query by date using the aggregation framework, you're responsible for ensuring that you're passing in a valid date. +
**Q**. Why don't in-place modifications to date objects @@ -445,6 +460,7 @@ block content [perDocumentLimit](/docs/populate.html#limit-vs-perDocumentLimit) option (new in Mongoose 5.9.0). Just keep in mind that populate() will execute a separate query for each document. +
**Something to add?**