a. *_* g. 2 mongodb pymongo python-3.x
我有dateFromString运营商的问题
我想使用dateFromString运算符从字符串中解析日期。日期位于某个集合的“已发布”字段中
我正在使用 Python 3.6.4,MongoDB shell 版本 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)))
Run Code Online (Sandbox Code Playgroud)
谢谢
| 归档时间: |
|
| 查看次数: |
2153 次 |
| 最近记录: |