如何解决在NoSql中插入带有Date的生日
我试图像这样在NoSQL中插入具有Date类型的生日
db.employees.insertOne({
"Name": "Alison Davison",birthday: Date("Apr 05,1975"),"Address": "874 W. Oak Place","City": "Gary","State": "Indiana",Position:{Name: "Customer Support",Remote: true,Full Time: true}
});
并抛出此错误
uncaught exception: SyntaxError: missing : after property id :
@(shell):7:63
解决方法
您需要在package.json
{
"name": "test","version": "1.0.0","description": "test","main": "index.js","scripts": {
"test": "echo \"Error: no test specified\" && exit 1","start": "electron ."
},"author": "","license": "ISC","dependencies": {
"electron": "^9.2.0","electron-packager": "^15.0.0"
}
}
构造函数中使用受支持的格式。
Date
您尝试的格式不支持默认格式。
并且请使用以下内容。您的钥匙中有一个空格。用引号将其括起来。
new Date("<YYYY-mm-dd>") returns the ISODate with the specified date.
new Date("<YYYY-mm-ddTHH:MM:ss>") specifies the datetime in the client’s local timezone and returns the ISODate with the specified datetime in UTC.
new Date("<YYYY-mm-ddTHH:MM:ssZ>") specifies the datetime in UTC and returns the ISODate with the specified datetime in UTC.
new Date(<integer>) specifies the datetime as milliseconds since the Unix epoch (Jan 1,1970),and returns the resulting ISODate instance.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。