Reputation: 108
I just wanted to know is there any specific datatype for time
or we have to use Date
data type. Like i am creating an app where a chef will give total time the dish will take to be ready. Now i am creating a mongoose model.
cookTime: {
type: Date,
required: true,
},
is there any way by which i can just store time like 10:50 pm
instead of 2021-06-22T21:30:34.736+00:00
.
Thanks in advance.
Upvotes: 0
Views: 558
Reputation: 37018
No, there is not for obvious reasons.
Types available out of the box are documented here https://mongoosejs.com/docs/schematypes.html#what-is-a-schematype
You can implement a custom type as described in https://mongoosejs.com/docs/schematypes.html#customtypes
It's not quite clear what type you expect on nodejs level but you are limited to one of bson types on the database level https://docs.mongodb.com/manual/reference/bson-types/
Upvotes: 1