I want to query mongo for "unexpired or evergreen(posts with null expiration) posts created or bookmarked by me"
The problem with my query is that mongoose is combining the or statements together so that I'm incorrectly getting (unexpired or evergreen or mine or bookmarked)
rather than ( (unexpired or evergreen) and (mine or bookmarked) )
How do I change the mongoose query to be the latter correct case I outlined above. Should I use an "and" clause... or perhaps I should just do a not(expiration > now) ?
var query =
Invite.find({ isActive:true })
.or([
{ 'expiration': {$gt: new Date()} },
{ 'expiration' : null }
])
.or([
{ createdBy:userId },
{ 'bookmarked.id' : userId }
])