Skip to content

Commit

Permalink
Merge pull request #11171 from Automattic/FAQ-update
Browse files Browse the repository at this point in the history
Updated docs and issue templates for new FAQs
  • Loading branch information
vkarpov15 authored Jan 20, 2022
2 parents eccf89f + a9f8218 commit 563810b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
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
38 changes: 38 additions & 0 deletions docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,44 @@ 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
```

<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 allow Mongoose to connect.
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.
If you're storing schemas or models in a separate npm package, please list Mongoose in `peerDependencies` rather than `dependencies` in your separate package.

<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

0 comments on commit 563810b

Please sign in to comment.