1

I'm developing a web service using MEAN stack + Mongoose, and one of the things I need to implement is storing a date as an object's field. But the thing is, the time should be optional, e.g. the user should be able to save an object filling in only the date without time.

How can I achieve this result? And how can I search on this field later?

1

You can always insert object with type "date" (type 9), no special codes needed. As you can always insert it as "string" or ISODate.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.