Hi I have a collection named \"my_sales\" having fields product_name, price, sale_date.
My doc looks like
{ \"_id\" : ObjectId(\"5458b6ee09d76eb7
I have new way to query date range:
// convert to date fromTime := time.Unix(1509358405981/1000, 0) // Convert date to ObjectID with time fromObjectBson := bson.NewObjectIdWithTime(fromTime) // condition bson.M{"_id":bson.M{"$gt": fromObjectBson}}
This will speedup your query.