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

TypeScript Model incorrect number of arguments #10817

Closed
ahmedelshenawy25 opened this issue Sep 30, 2021 · 0 comments
Closed

TypeScript Model incorrect number of arguments #10817

ahmedelshenawy25 opened this issue Sep 30, 2021 · 0 comments
Labels
typescript Types or Types-test related issue / Pull Request
Milestone

Comments

@ahmedelshenawy25
Copy link
Contributor

ahmedelshenawy25 commented Sep 30, 2021

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

What is the current behavior?
Model expects 1 argument

If the current behavior is a bug, please provide the steps to reproduce.

import mongoose from 'mongoose';

interface IBook {
  name?: string;
}

async function run() {
  await mongoose.connect('mongodb://localhost:27017/test');

  const bookSchema = new mongoose.Schema<IBook>({
    name: String,
  });

  const Book = mongoose.model<IBook>('Book', bookSchema);
  const book = new Book({ name: 'aaaa' }, null , true);
  console.log(book);
}

run().catch(console.error);
{
  "compilerOptions": {
    "target": "ES6",
    "module": "commonjs",
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "skipLibCheck": true
  }
}

What is the expected behavior?
Model should expect up to 3 arguments
https://mongoosejs.com/docs/api.html#model_Model

What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Node.js: v14.15.5
Mongoose: v6.0.8
MongoDB: v4.4.3

@IslandRhythms IslandRhythms added the typescript Types or Types-test related issue / Pull Request label Sep 30, 2021
@vkarpov15 vkarpov15 added this to the 6.0.10 milestone Oct 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
typescript Types or Types-test related issue / Pull Request
Projects
None yet
Development

No branches or pull requests

3 participants