Migrate to a Later API Version迁移到更高版本的API

On this page本页内容

Compatibility with Future Versions与未来版本的兼容性

The only API version that currently exists is "1", but there will be new API versions released in the future. 目前唯一存在的API版本是“1”,但将来会发布新的API版本。Upgrading your API version provides improved functionality and semantics for your application.升级API版本可以为应用程序提供改进的功能和语义。

Some API V1 commands and behaviors will be deprecated in future versions of the MongoDB server. 一些API V1命令和行为将在MongoDB服务器的未来版本中弃用。Deprecated commands and behaviors are typically not included in the next API version.不推荐使用的命令和行为通常不会包含在下一个API版本中。

Find Deprecated Commands and Behaviors查找不推荐的命令和行为

To migrate an existing application from API V1 to API V2, you must find and update all of the deprecated commands and behaviors features it uses.要将现有应用程序从API V1迁移到API V2,必须找到并更新其使用的所有不推荐使用的命令和行为功能。

client = MongoClient(
  <connection string>,
  api={"version": "1", "strict": True, "deprecationErrors": True}
)

The returns a APIDeprecationError if your application code tries to use commands and behaviors deprecated in API V1. 如果应用程序代码尝试使用API V1中不推荐使用的命令和行为,则返回APIDeprecationErrorOnce your application tests pass and all deprecation errors have been fixed, you will be ready to test your application with API V2.一旦应用程序测试通过并修复了所有弃用错误,您就可以使用API V2测试应用程序了。

←  Stable APIRelease Notes →