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

can’t set property 'family' of MongooseModule options #256

Closed
vincentdd opened this issue Jan 30, 2020 · 1 comment
Closed

can’t set property 'family' of MongooseModule options #256

vincentdd opened this issue Jan 30, 2020 · 1 comment

Comments

@vincentdd
Copy link

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

can't set property 'family' of options in MongooseModule.forRoot
console log when compile:

src/app.module.ts:24:58 - error TS2345: Argument of type '{ useNewUrlParser: boolean; useCreateIndex: boolean; useFindAndModify: boolean; autoIndex: boolean; reconnectTries: number; reconnectInterval: number; poolSize: number; bufferMaxEntries: number; connectTimeoutMS: number; socketTimeoutMS: number; family: number; }' is not assignable to parameter of type 'MongooseModuleOptions'.
Types of property 'family' are incompatible.
Type 'number' is not assignable to type '4 | 6'.

24 imports: [BillsModule, MongooseModule.forRoot(mongoDB, options)],

Expected behavior

be able to set property 'family' to 4

Minimal reproduction of the problem with instructions

my options:

const options = {
  useNewUrlParser: true,
  useCreateIndex: true,
  useFindAndModify: false,
  autoIndex: false, // Don't build indexes
  reconnectTries: Number.MAX_VALUE, // Never stop trying to reconnect
  reconnectInterval: 500, // Reconnect every 500ms
  poolSize: 10, // Maintain up to 10 socket connections
  // If not connected, return errors immediately rather than waiting for reconnect
  bufferMaxEntries: 0,
  connectTimeoutMS: 10000, // Give up initial connection after 10 seconds
  socketTimeoutMS: 45000, // Close sockets after 45 seconds of inactivity
  family: 4 // Use IPv4, skip trying IPv6
}

What is the motivation / use case for changing the behavior?

Environment


Nest version: 6.10.14
@types/mongoose:  5.7.0

 
For Tooling issues:
- Node version: 12.9.1
- Platform:   Windows

Others:

@vincentdd
Copy link
Author

I found my mistake.I should call forRoot like this:

MongooseModule.forRoot(mongoDB, {
    useNewUrlParser: true,
    useCreateIndex: true,
    useFindAndModify: false,
    autoIndex: false, // Don't build indexes
    reconnectTries: Number.MAX_VALUE, // Never stop trying to reconnect
    reconnectInterval: 500, // Reconnect every 500ms
    poolSize: 10, // Maintain up to 10 socket connections
    // If not connected, return errors immediately rather than waiting for reconnect
    bufferMaxEntries: 0,
    connectTimeoutMS: 10000, // Give up initial connection after 10 seconds
    socketTimeoutMS: 45000, // Close sockets after 45 seconds of inactivity
    family: 4 // Use IPv4, skip trying IPv6
  })

sorry ,I'm freshman for TS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant