10

I currently have this call:

 const q = coll.find(query, {
    tailable: true,
    awaitData: true,
    oplogReplay: true,
    noCursorTimeout: true,
    numberOfRetries: Number.MAX_VALUE
  });

 return q.stream()

but my IDE warns me that this method on mongodb.Collection is deprecated:

enter image description here

Sure enough that's what the typings say. My question is - what is the long term solution here, what is the new way to make this same call?

  • note that this is `find()` on a Collection type –  Mar 17 '18 at 04:00
  • Not sure why it's marked as deprecated in the typings, as it's not marked that way in the current [API docs](http://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#find). – JohnnyHK May 14 '20 at 13:13

1 Answers1

0

This seems to work, but is very verbose, and I am not sure if there is not a better way to do it:

 const q = coll.find(query)
  .addCursorFlag('tailable', true)
  .addCursorFlag('awaitData', false)
  .setCursorOption('numberOfRetries', Number.MAX_VALUE)
  .setCursorOption('tailableRetryInterval', 200)
  .addCursorFlag('noCursorTimeout', true)
  .addCursorFlag('oplogReplay', true);

note that the booleans, you need to use addCursorFlag, but the non-booleans need to use setCursorOption....seems weird/unnecessary.