2
db.events.update(
{upload:0},
{$set:{upload:1}},
{multi:true}
)
即使我只是用另一个整数替换整数,我仍然收到以下错误。如何更新MongoDB中加盖集合中的单个字段?
Cannot change the size of a document in a capped collection: 402 != 406
db.events.update(
{upload:0},
{$set:{upload:1}},
{multi:true}
)
即使我只是用另一个整数替换整数,我仍然收到以下错误。如何更新MongoDB中加盖集合中的单个字段?
Cannot change the size of a document in a capped collection: 402 != 406
它看起来像你插入double
而不是int32
(double
是4字节比int32
宽)。
NumberInt
蒙戈外壳将所有编号为浮点值由 默认。 mongo shell提供的NumberInt()构造函数为 ,明确指定了32位整数。
要解决这个问题,只要你的代码改成这样:
db.events.update(
{upload:0},
{$set:{upload: NumberInt(1)}},
{multi:true}
)
你确定你没有更新的整数值'{上传:0}'双值'{上传:1}' ?您可以通过运行db.events.find({upload:{$ type:'int'}})'来查看它是否返回任何文档以进行验证。你在shell中运行查询吗? – Veeram