## Bug
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
## Feature
- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`
## Documentation / Examples
- [ ] Make sure the linting passes by running `yarn lint`
* Update to use the latest MongoDB best practices.
* lint-fix
Co-authored-by: Lee Robinson <me@leerob.io>
Co-authored-by: jj@jjsweb.site <jj@jjsweb.site>
I've looked at the example code and saw some consistent issues related to code style. The changes applied to this PR fixes the following points:
- Differences of line breaks styles between multiple files
- Differences of if statements styles
- Unnecessary comment
- A typo on a JSDocs
---
There were line breaks between statements on `pages/index.js`
````
export async function getServerSideProps(context) {
const { client } = await connectToDatabase()
const isConnected = await client.isConnected()
return {
props: { isConnected },
}
}
````
And this wasn't being applied to the MongoDB utility:
````
export async function connectToDatabase() {
if (cached.conn) return cached.conn
if (!cached.promise) {
const conn = {}
const opts = {
useNewUrlParser: true,
useUnifiedTopology: true,
}
{...}
````
And also, as shown in the snippet above, there are different styles of if statements being used.
With that being said, the reason I made this PR is because I think that this kind of inconsistent arises questions when a contributor looks to the codebase, even if this is a simple example.
* MongoDB Example
* Apply suggestions from code review
* Add changes based on feedback.
* clean up code with more descriptive props
* Use MongoDB in ServerSideProps instead of separate API route
* Update examples/with-mongodb/README.md
Co-authored-by: Luis Alvarez D. <luis@vercel.com>
* Update examples/with-mongodb/README.md
Co-authored-by: Luis Alvarez D. <luis@vercel.com>
* Update examples/with-mongodb/README.md
Co-authored-by: Luis Alvarez D. <luis@vercel.com>
* Update examples/with-mongodb/README.md
Co-authored-by: Luis Alvarez D. <luis@vercel.com>
* Update examples/with-mongodb/README.md
Co-authored-by: Luis Alvarez D. <luis@vercel.com>
* Update examples/with-mongodb/README.md
Co-authored-by: Luis Alvarez D. <luis@vercel.com>
* Update examples/with-mongodb/README.md
Co-authored-by: Luis Alvarez D. <luis@vercel.com>
Co-authored-by: Luis Alvarez D <luis@vercel.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>