From 7727c84a3b89212c7eea1eea015d0c01b157c2c5 Mon Sep 17 00:00:00 2001 From: Daniel Diaz <39510674+IslandRhythms@users.noreply.github.com> Date: Mon, 3 Jan 2022 11:33:48 -0500 Subject: [PATCH 1/4] Updated docs and issue templates for new FAQs --- .github/ISSUE_TEMPLATE.md | 4 ++++ docs/faq.md | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index b5e10873385..66d2b5452e3 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,5 +1,9 @@ + + + + **Do you want to request a *feature* or report a *bug*?** **What is the current behavior?** diff --git a/docs/faq.md b/docs/faq.md index 8c6341ce907..5ff4aea230d 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -12,6 +12,28 @@ hr { } +
+ +**Q**. Operation `...` timed out after 10000 ms. What gives? + +**A**. At its core, this issue stems from being unable to connect to mongoose. If you are using an application, like a bot, +that wishes to connect to mongoose, you must ensure that you are connecting before the bot bot activates. For example, when working +with discord bots, the last line of your index file is `client.login(token)`. You want to place the connection string, `mongoose.connect().then()` before this line. +Do not place it in an event handler like `client.on('message')`, as this activates after you have logged in to the bot. + + **Q**. I am able to connect locally but when I try to connect to a server I get this error. What gives? + +You must ensure that you have whitelisted your ip on [mongodb](https://docs.atlas.mongodb.com/security/ip-access-list/) to let it connect. +If security is of no concern for your application, like a personal project that doesn't use user's information, you can allow access from all +ips with `0.0.0.0/0`. + +
+ +**Q**. x.$__y is not a function. What gives? + +**A**. This issue is a result of having multiple versions of mongoose installed that are incompatible with each other. Run `npm list | grep "mongoose"` to +find and remedy the problem. +
**Q**. I declared a schema property as `unique` but I can still save duplicates. What gives? From 5d1785409531f777840388432c8d5fca1dc8a364 Mon Sep 17 00:00:00 2001 From: Daniel Diaz <39510674+IslandRhythms@users.noreply.github.com> Date: Mon, 3 Jan 2022 12:53:59 -0500 Subject: [PATCH 2/4] typo fix --- docs/faq.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/faq.md b/docs/faq.md index 5ff4aea230d..59b8c7bbbbc 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -17,7 +17,7 @@ hr { **Q**. Operation `...` timed out after 10000 ms. What gives? **A**. At its core, this issue stems from being unable to connect to mongoose. If you are using an application, like a bot, -that wishes to connect to mongoose, you must ensure that you are connecting before the bot bot activates. For example, when working +that wishes to connect to mongoose, you must ensure that you are connecting before the bot activates. For example, when working with discord bots, the last line of your index file is `client.login(token)`. You want to place the connection string, `mongoose.connect().then()` before this line. Do not place it in an event handler like `client.on('message')`, as this activates after you have logged in to the bot. From 20b9fe7d2c01b8d94968085792ae2ab814302657 Mon Sep 17 00:00:00 2001 From: Daniel Diaz <39510674+IslandRhythms@users.noreply.github.com> Date: Wed, 5 Jan 2022 11:01:17 -0500 Subject: [PATCH 3/4] made most requested changes --- .github/ISSUE_TEMPLATE.md | 4 ++-- docs/faq.md | 32 ++++++++++++++++++++++++++------ 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 66d2b5452e3..29d4c024659 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,8 +1,8 @@ - + - + **Do you want to request a *feature* or report a *bug*?** diff --git a/docs/faq.md b/docs/faq.md index 59b8c7bbbbc..459b98ae9d5 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -16,16 +16,36 @@ hr { **Q**. Operation `...` timed out after 10000 ms. What gives? -**A**. At its core, this issue stems from being unable to connect to mongoose. If you are using an application, like a bot, -that wishes to connect to mongoose, you must ensure that you are connecting before the bot activates. For example, when working -with discord bots, the last line of your index file is `client.login(token)`. You want to place the connection string, `mongoose.connect().then()` before this line. +**A**. At its core, this issue stems from not connecting to MongoDB. +You can use Mongoose before connecting to MongoDB, but you must connect at some point. For example: + +```javascript +await mongoose.createConnection(mongodbUri); + +const Test = mongoose.model('Test', schema); + +await Test.findOne(); // Will throw "Operation timed out" error because didn't call `mongoose.connect()` +``` + +```javascript +await mongoose.connect(mongodbUri); + +const db = mongoose.createConnection(); + +const Test = db.model('Test', schema); + +await Test.findOne(); // Will throw "Operation timed out" error because `db` isn't connected to MongoDB +``` + +If you are using an application, like a bot, that wishes to connect to Mongoose, you must ensure that you are connecting before the bot activates. +For example, when working with discord bots, the last line of your index file is `client.login(token)`. +You want to place the connection string, `mongoose.connect().then()` before this line. Do not place it in an event handler like `client.on('message')`, as this activates after you have logged in to the bot. - **Q**. I am able to connect locally but when I try to connect to a server I get this error. What gives? + **Q**. I am able to connect locally but when I try to connect to MongoDB Atlas I get this error. What gives? You must ensure that you have whitelisted your ip on [mongodb](https://docs.atlas.mongodb.com/security/ip-access-list/) to let it connect. -If security is of no concern for your application, like a personal project that doesn't use user's information, you can allow access from all -ips with `0.0.0.0/0`. +You can allow access from all ips with `0.0.0.0/0`.
From a9f8218ebebd60c8b38c176a7a95a90283e49d43 Mon Sep 17 00:00:00 2001 From: Daniel Diaz <39510674+IslandRhythms@users.noreply.github.com> Date: Tue, 11 Jan 2022 12:54:44 -0500 Subject: [PATCH 4/4] made requested changes --- docs/faq.md | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/docs/faq.md b/docs/faq.md index 459b98ae9d5..a1cb87e7afb 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -37,22 +37,18 @@ const Test = db.model('Test', schema); await Test.findOne(); // Will throw "Operation timed out" error because `db` isn't connected to MongoDB ``` -If you are using an application, like a bot, that wishes to connect to Mongoose, you must ensure that you are connecting before the bot activates. -For example, when working with discord bots, the last line of your index file is `client.login(token)`. -You want to place the connection string, `mongoose.connect().then()` before this line. -Do not place it in an event handler like `client.on('message')`, as this activates after you have logged in to the bot. - **Q**. I am able to connect locally but when I try to connect to MongoDB Atlas I get this error. What gives? -You must ensure that you have whitelisted your ip on [mongodb](https://docs.atlas.mongodb.com/security/ip-access-list/) to let it connect. +You must ensure that you have whitelisted your ip on [mongodb](https://docs.atlas.mongodb.com/security/ip-access-list/) to allow Mongoose to connect. You can allow access from all ips with `0.0.0.0/0`.
**Q**. x.$__y is not a function. What gives? -**A**. This issue is a result of having multiple versions of mongoose installed that are incompatible with each other. Run `npm list | grep "mongoose"` to -find and remedy the problem. +**A**. This issue is a result of having multiple versions of mongoose installed that are incompatible with each other. +Run `npm list | grep "mongoose"` to find and remedy the problem. +If you're storing schemas or models in a separate npm package, please list Mongoose in `peerDependencies` rather than `dependencies` in your separate package.