我对dateFromString
操作符有个问题
我想使用dateFromString
操作符解析字符串中的日期。日期在某个集合中的“已发布”字段中。
我使用Python3.6.4,MongoDB外壳版本v3.6.2,pymongo '3.6.0‘我收到以下错误消息:
pymongo.errors.OperationFailure:无法识别的表达式“$dateFromString”
有人能帮忙吗?
这是我的密码
pipeline = [
{
'$limit' : 100
},
{
'$project' : {
'released': {
'$cond': {
'if': {'$eq': ['$released', '']},
'then': '',
'else': {
'$dateFromString':{
'dateString': '$released'
}
}
}
},
}
},
{
'$out': 'movies_scratch'
}
]
pprint.pprint(list(client.database.collection.aggregate(pipeline)))
thx
发布于 2018-02-28 03:39:00
检查mongoDB数据库版本。如果您使用的是阿特拉斯免费层,它仍然在3.4.13版本。您需要一个mongoDB 3.6版本才能使$dateFromString工作。
https://stackoverflow.com/questions/48271678
复制相似问题