Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated docs and issue templates for new FAQs #11171

Merged
merged 4 commits into from
Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<!-- *Before creating an issue please make sure you are using the latest version of mongoose -->

<!-- *Getting a `Operaion ... timed out after 10000ms` error? Read this FAQ entry: https://mongoosejs.com/docs/faq.html#operation-buffering-timed-out -->

<!-- *Getting a `x.$__y is not a function` error? Read this FAQ entry: https://mongoosejs.com/docs/faq.html#not-a-function -->

**Do you want to request a *feature* or report a *bug*?**

**What is the current behavior?**
Expand Down
42 changes: 42 additions & 0 deletions docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,48 @@ hr {
}
</style>

<hr id="operation-buffering-timed-out" />

<a class="anchor" href="#operation-buffering-timed-out">**Q**</a>. Operation `...` timed out after 10000 ms. What gives?

**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.
IslandRhythms marked this conversation as resolved.
Show resolved Hide resolved
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.

<a class="anchor" href="#not-local"> **Q**</a>. 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.
IslandRhythms marked this conversation as resolved.
Show resolved Hide resolved
You can allow access from all ips with `0.0.0.0/0`.

<hr id="not-a-function" />

<a class="anchor" href="#not-a-function">**Q**</a>. 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.
IslandRhythms marked this conversation as resolved.
Show resolved Hide resolved

<hr id="unique-doesnt-work" />

<a class="anchor" href="#unique-doesnt-work">**Q**</a>. I declared a schema property as `unique` but I can still save duplicates. What gives?
Expand Down