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

Type error will appear in createConnection #12618

Closed
2 tasks done
shibin-cli opened this issue Oct 31, 2022 · 2 comments · Fixed by #12620
Closed
2 tasks done

Type error will appear in createConnection #12618

shibin-cli opened this issue Oct 31, 2022 · 2 comments · Fixed by #12620
Labels
docs This issue is due to a mistake or omission in the mongoosejs.com documentation
Milestone

Comments

@shibin-cli
Copy link

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Mongoose version

6.7.0

Node.js version

16.16.0

MongoDB server version

6.0.0

Typescript version (if applicable)

4.8.0

Description

If you use the official website sample code to connect to the database, there will be a TS error

Steps to Reproduce

Use the official website example code

import { createConnection } from 'mongoose';
const opts = { server: { auto_reconnect: false }, user: 'username', pass: 'mypassword' };
const db = createConnection('localhost', 'database', 27017, opts);

Ts error occurs

Expected 0-3 arguments, but got 4.

Expected Behavior

No response

@irham01
Copy link

irham01 commented Oct 31, 2022

+1

@lpizzinidev
Copy link
Contributor

lpizzinidev commented Nov 1, 2022

It's probably just an outdated example remaining from #6766 since the mongoose.createConnection(host, dbname, port) syntax is no longer supported as you can see:

mongoose/lib/connection.js

Lines 686 to 691 in 25cd782

if (['string', 'number'].indexOf(typeof options) !== -1) {
throw new MongooseError('Mongoose 5.x no longer supports ' +
'`mongoose.connect(host, dbname, port)` or ' +
'`mongoose.createConnection(host, dbname, port)`. See ' +
'https://mongoosejs.com/docs/connections.html for supported connection syntax');
}

@IslandRhythms IslandRhythms added the docs This issue is due to a mistake or omission in the mongoosejs.com documentation label Nov 1, 2022
@vkarpov15 vkarpov15 added this to the 6.7.1 milestone Nov 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This issue is due to a mistake or omission in the mongoosejs.com documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants