手机
当前位置:查字典教程网 >编程开发 >MongoDB >mongodb exception: $concat only supports strings, not NumberInt32解决办法
mongodb exception: $concat only supports strings, not NumberInt32解决办法
摘要:今天在用mongodb操作aggregation的时候出现这个问题,我是想格式化日期,例如”2013-10-1704:41:37UTC”变成...

今天在用mongodb操作aggregation的时候出现这个问题,我是想格式化日期,例如”2013-10-17 04:41:37 UTC”变成”10月17日”,

复制代码 代码如下:

'fdate' => { '$concat' => ['$date.month', '月', '$date.day', '日'] }

出现 exception: $concat only supports strings, not NumberInt32

原来$concat只能操作字符串,不支持数字类型,解决办法是用$substr

复制代码 代码如下:

$date形如'2013-10-13 11:17:18 UTC'

'fdate' => { '$concat' => [ {$substr=>['$date', 5, 2]}, '月', {$substr=>['$date', 8, 2]}, '日'] }

$substr接受两个参数,一个是字符串的起点,一个是截取的字符串的长度。

【mongodb exception: $concat only supports strings, not NumberInt32解决办法】相关文章:

详解MongoDB中创建集合与删除集合的操作方法

MongoDB错误32-bit servers don't have journaling enabled by default解决方法

MongoDB的一些常用查询方法

MongoDB入门教程(包含安装、常用命令、相关概念、使用技巧、常见操作等)

mongodb错误tcmalloc: large alloc out of memory, printing stack and exiting解决办法

MongoDB aggregate 运用篇个人总结

MongoDB系列教程(三):Windows中下载和安装MongoDB

MongoDB 使用Skip和limit分页

十个提高MongoDB安全性的配置技巧

MongoDB各种查询操作详解

精品推荐
分类导航