Fixed bad logical operator test for setting expireAfterSeconds option… #78
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I was trying to implement the new expireAfterSeconds option to winston-mongodb and the TTL index was not created on any of my logging collections, even if I dropped the collections and let winston-mongodb recreate them. I believe that the problem is that despite the docs saying that the expireAfterSeconds option only is in play if the capped option is NOT set, the code for setting the expireAfterSeconds option actually has a logical operator test that checks if 'this.capped && options.expireAfterSeconds'. With that test, if capped is set as false or false via default, then the expireAfterSeconds option is actually not evaluated.
I tested simply changing this.capped to !this.capped and the result was successful creation of my logging collections with the TTL index.
Note I am testing on 1.6.5 since we are not ready to move to node 6.x but the change is a one liner and so should apply just the same on the 2.x version.