Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我希望能够从字符串转换为 int 特定字段。到目前为止,我唯一的方法是让我的 PHP 脚本通过 API 调用来更新所有现有值,该 API 调用具有该字段的每个文档。有没有办法 1)MongoLab 更新值在更新调用中利用现有值(即在 SQL 中你可以这样做price = price + 1)和 2)你可以在 MongoDB/MongoLab 更新调用中调用函数吗?即{"price":"integer(price)"}?
price = price + 1
{"price":"integer(price)"}
您将必须编写一个程序来遍历所有数据并手动进行转换。在 mongo shell 中运行一个简单的 Javascript 程序可能是最简单的方法。