【问题标题】:How to get the list of Collections in DocumentDB using Java API?如何使用 Java API 获取 DocumentDB 中的集合列表?
【发布时间】:2015-06-08 16:53:51
【问题描述】:

我想使用 Java 获取 DocumentDB 中的集合列表。我该怎么做?

【问题讨论】:

    标签: azure azure-cosmosdb nosql


    【解决方案1】:

    查看https://github.com/shipunyc/azure-documentdb-java/blob/master/src/com/microsoft/azure/documentdb/test/GatewayTests.java#L356

    DocumentClient 客户端 = new DocumentClient(HOST, MASTER_KEY, ConnectionPolicy.GetDefault(), ConsistencyLevel.Session); 列表集合 = client.readCollections(this.databaseForTest.getSelfLink(), null).getQueryIterable().toList();

    【讨论】:

    • 我应该把什么写成.databaseForTest.getSelfLink()?它可以是带有我的数据库名称的字符串吗?
    • 不,它不是带有数据库名称的字符串。 databaseForTest 必须是从系统读取的 Database 类的实例。在这个类的实例上,getSelfLink() 将返回应该使用的链接。它看起来像 dbs/prdnAA==/ ... 其中 prdnAA== 是创建数据库时分配给数据库的资源 ID(或 _rid)。
    猜你喜欢
    • 1970-01-01
    • 2018-11-14
    • 2011-09-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-03
    • 1970-01-01
    相关资源
    最近更新 更多