db.events.update(
{upload:0},
{$set:{upload:1}},
{multi:true}
)
I am getting the following error even though I am just replacing an integer with another integer.
Cannot change the size of a document in a capped collection: 402 != 406
db.events.update(
{upload:0},
{$set:{upload:1}},
{multi:true}
)
I am getting the following error even though I am just replacing an integer with another integer.
Cannot change the size of a document in a capped collection: 402 != 406
看起来您插入的是 adouble
而不是int32
(double
比 宽 4 个字节int32
)。
来自mongodb 类型文档:
整数
默认情况下,mongo shell 将所有数字视为浮点值。mongo shell 提供 NumberInt() 构造函数来显式指定 32 位整数。
要解决此问题,只需将您的代码更改为:
db.events.update(
{upload:0},
{$set:{upload: NumberInt(1)}},
{multi:true}
)