mongotemplate 'can't convert from BSON type array to Date'

A与B对应关系是1:n,我想格式化B的日期报错:

ProjectionOperation project1 = Aggregation.project(""updatedDt"
                ,"B.createdDt")


.andExpression("{ $dateToString: {date: '$B.createdDt[0]', format: '%Y-%m-%d %H:%M:%S', timezone: '+08:00'}}").as("chat2Dt")
com.mongodb.MongoCommandException: Command failed with error 16006 (Location16006): 'can't convert from BSON type array to Date' on server test-seaurl.mongodb.rds.aliyuncs.com:3717. The full response is {"ok": 0.0, "errmsg": "can't convert from BSON type array to Date", "code": 16006, "codeName": "Location16006", "operationTime": {"$timestamp": {"t": 1641714252, "i": 1}}, "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1641714255, "i": 86}}, "signature": {"hash": {"$binary": {"base64": "ox+iGHeWaQimZxpyHsHkFCV50Bk=", "subType": "00"}}, "keyId": 7018457078310109185}}}
阅读 2.1k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进