.addCursorFlag() is not available on Mongoose Typescript

566 Views Asked by At

Below is my mongoose model and I read data from db via cursor. My cursor times out after 10 minutes as mentioned in the documentation.

const cursor = this.importRecordModel.find().cursor()

I am trying to add below to the end of the cursor but either because of typescript or mongoose, It is not on the available functions list.

.addCursorFlag('noCursorTimeout', true);

enter image description here

1

There are 1 best solutions below

2
On

I'm assuming you're using @mongoose/types if not correct me and tell me which types file you're using.

The types file is not 100% updated correctly, as you can see addCursorFlag is only available for an aggregation cursor although mongoose does have support for QueryCursor addCursorFlag as seen here.

I recommend you just add //@ts-ignore on top of it and move on. if you want to open a PR and add missing methods to that library you're also welcome to.

Personally I dumped mongoose over a year ago and never looked back. I encourage other people to do the same.