These are chat archives for Automattic/mongoose

27th
Oct 2018
Ghost
@ghost~5b53da7dd73408ce4fa1d2e5
Oct 27 2018 03:22
how to query date in mongoose?
Kev
@lineus
Oct 27 2018 08:33
@Teoreez I just came back and read what I wrote in the channel yesterday about not using .exec and .then at the same time. Not sure why I said it that way, what I meant was, you don't need to use .exec() after .then(). the gist is still there and unchanged
Kev
@lineus
Oct 27 2018 10:17

@gallor I'm fairly certain that if the underlying mongodb driver can connect to the replica set as a whole, you won't see any errors from the driver, and by extension mongoose. It would be fairly inexpensive though to connect to each replica host directly ( immediately closing any that succeed and logging the ones that don't ).

For example, I have a local replicaSet running on ports 270{17,18,19}. In this example gist I try to connect to 270{17,18,20}. Even though one of the replica hosts in my connection string doesn't exist, mongoose ( via the driver ) is still able to connect to the replicaSet, insert a doc, and retrieve it without error ( except the one I manually create by connecting directly to it ).

Kev
@lineus
Oct 27 2018 10:46
@isemaj_gitlab you can pass in either a Date object or a number and use mongodb's comparison operators [$gt, $gte, $lt, $lte, $eq, $ne] with [$and, $or] as needed. Here's an example gist