Home >Database >Mysql Tutorial >mongodb 更改数据类型

mongodb 更改数据类型

WBOY
WBOYOriginal
2016-06-07 16:32:291141browse

db.bmdMessage.find( { '_id' : { $type : 2 } } ).forEach( function (x) { x._id=ObjectId(x._id); db.bmdMessage.save(x); }); 注意:_id的类型创建了则不允许更改。 参考: 修改MongoDB 字段的类型 官方文档 原文地址:mongodb 更改数据类型, 感谢原作者

db.bmdMessage.find( { '_id' : { $type : 2 } } ).forEach( function (x) { x._id=ObjectId(x._id); db.bmdMessage.save(x); });

注意:_id的类型创建了则不允许更改。
参考:
修改MongoDB 字段的类型
官方文档

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Going with GoNext article:The Top 5 Metrics to Watch in MongoDB