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: Properties 'limit' and 'skip' do not exist on type Aggregate #9691

Closed
LuksTrackmaniaCorner opened this issue Dec 10, 2020 · 0 comments · Fixed by #9692
Closed

Comments

@LuksTrackmaniaCorner
Copy link

Do you want to request a feature or report a bug?
I'd like to report a bug

What is the current behavior?
I updated from Mongoose 5.10.19 with @types/mongoose to 5.11.6 and got a new error from typescript:
error TS2339: Property 'limit' does not exist on type 'Aggregate<any[]>'
on a line like this:
const data = await Model.aggregate(aggregationPipeline).skip(skip).limit(limit);

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

Compiling the following with typescript should reproduce the issue:

import mongoose from 'mongoose';

mongoose.connect('mongodb://localhost:27017/test', {
  useNewUrlParser: true,
  useCreateIndex: true,
  useUnifiedTopology: true,
});

const personSchema = new mongoose.Schema({name: String})
const personModel = mongoose.model('Person', personSchema);

const doSomething = async () => {
  const data = await personModel.aggregate().skip(10).limit(10);
  console.log(data);
}

doSomething();

What is the expected behavior?
The program should compile as before

What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
NodeJs: 14.11.0
Mongoose: 5.11.6
MongoDB: 4.2.9

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

Successfully merging a pull request may close this issue.

1 participant