for my MEAN stack project I have to store a Date object in MongoDB for the start and end of a booking. the Date goes in just fine, in my collection it's show as:
booking_start: 2022-12-16T00:00:00.000+00:00
booking_end: 2022-12-29T00:00:00.000+00:00
but when i query my collection for all entries the Dates come out as strings of numbers like this
"booking_start": "1671148800000",
"booking_end": "1672272000000"
what is going on here? I'll admit I'm new to working with Dates in Mongo but why is happening? I am using Graphql for my queries, but i don't think that the problem. is there a special way to query a Date?
here is my code and queries
resolver
getuserbooking: async ()=>{
const userListinglist = userbooking.find({})
return userListinglist
}
it's schema
type Query {
getuserbooking:[userbooking]
}
and it's mongoose model
booking_date:{
type: Date,
default: Date.now,
required:[true,"Please enter booking date"],
},
booking_start:{
type: Date,
required:[true,"Please enter booking start"],
},
booking_end:{
type: Date,
required:[true,"Please enter booking end"]
Please any help would be greatly appreciated