I have mongo document like this
Document
{
“_id” : ObjectId(“5f73845ffb2a1a44d94d1245”),
“version” : 1.0,
“employerId” : “123456”,
“firstName” : “test”,
“lastName” : “testname”,
“contract” : [
{
“effectiveStartDt” : ISODate(“2020-09-06T00:00:00.000Z”),
“effectiveEndDt” : ISODate(“2020-09-30T00:00:05.000Z”),
“vendorName” : “Accenture”
},
{
“effectiveStartDt” : ISODate(“2020-10-06T00:00:00.000Z”),
“effectiveEndDt” : ISODate(“2020-10-31T00:00:00.000Z”),
“vendorName” : “TCS”
}
]
}
I wrote a query to find all contracts, where the current date is within effectiveStartDt and effectiveEndDt for a employerId.
err := cursor.Decode(&contract)
return contract ```
Go struct is defined like this
type Contract struct {
VendorName string `json:"vendorName" bson:"vendorName"`
EffectiveStartDt *time.Time `json:"effectiveStartDt" bson:"effectiveStartDt"`
EffectiveEndDt *time.Time `json:"effectiveEndDt" bson:"effectiveEndDt"`
}
result struct is setting date as null
[
{
"vendorName": "TCS",
"effectiveStartDt": null
"effectiveEndDt": null
}
]
appreciate if you can provide help with this