I am trying to upsert a record in MongoDB from nodejs. The JSON I am trying to insert is:
{
_id: { '$date': '2017-02-14T00:00:00Z' },
dayType: 'weekday',
endOfMonth: false,
finEndOfMonth: false,
_entity: [ 'holiday' ]
}
And I am getting this error: (MongoServerError: unknown operator: $date) Why is that happening?
Thanks in advance!
CodePudding user response:
Yes, $date
is not an operator to be used while inserting.
If you need to insert _id
as date
use one of predefined constructors
You could use new Date("2017-02-14T00:00:00Z")