データベース詳細の取得
https://$ACCOUNT.cloudant.com/$DATABASE
リクエストを送る GET
データベースに関する詳細を返します、 例えば、ドキュメントの数などです。
HTTP を使用してデータベースの詳細を取得する例を以下に示します。
GET /$DATABASE HTTP/1.1
データベースの詳細を取得するには、以下の例を参照してください。
curl -H "Authorization: Bearer $API_BEARER_TOKEN" -X GET "$SERVICE_URL/products"
import com.ibm.cloud.cloudant.v1.Cloudant;
import com.ibm.cloud.cloudant.v1.model.DatabaseInformation;
import com.ibm.cloud.cloudant.v1.model.GetDatabaseInformationOptions;
Cloudant service = Cloudant.newInstance();
GetDatabaseInformationOptions databaseInfoOptions =
new GetDatabaseInformationOptions.Builder()
.db("products")
.build();
DatabaseInformation response =
service.getDatabaseInformation(databaseInfoOptions).execute()
.getResult();
System.out.println(response);
const { CloudantV1 } = require('@ibm-cloud/cloudant');
const service = CloudantV1.newInstance({});
service.getDatabaseInformation({db: 'products'}).then(response => {
console.log(response.result);
});
from ibmcloudant.cloudant_v1 import CloudantV1
service = CloudantV1.new_instance()
response = service.get_database_information(db='products').get_result()
print(response)
getDatabaseInformationOptions := service.NewGetDatabaseInformationOptions(
"products",
)
databaseInformation, response, err := service.GetDatabaseInformation(getDatabaseInformationOptions)
if err != nil {
panic(err)
}
b, _ := json.MarshalIndent(databaseInformation, "", " ")
fmt.Println(string(b))
前の Go の例では、以下のインポート・ブロックが必要です。
import (
"encoding/json"
"fmt"
"github.com/IBM/cloudant-go-sdk/cloudantv1"
)
すべての Go の例では、service
オブジェクトを初期化する必要があります。 詳しくは、API 資料の認証セクションで例を参照してください。
返される構造体の要素を以下の表に示します。
フィールド | 説明 |
---|---|
compact_running |
データベース圧縮ルーチンがこのデータベースで作動している場合は、true に設定されます。 |
db_name |
データベースの名前。 |
disk_format_version |
ディスクに保管されるデータに使用される物理形式のバージョン。 |
disk_size |
ディスクに保管されているデータのサイズ (バイト)。 この計算にビューの索引は含まれません。 |
doc_count |
指定されたデータベースの文書数。 |
doc_del_count |
削除された文書数。 |
instance_start_time |
常に 0。 |
other |
data_size フィールドを含む JSON オブジェクト。 |
purge_seq |
データベースに対するパージ操作の数。 |
sizes |
file 、external 、およびactive のサイズを含む JSON オブジェクト。active は、内部に保管されているデータのサイズ(バイト単位)です(古いリビジョンを除く)。external は、圧縮解除されたユーザー・データのサイズ(バイト単位)です。 この値が、請求されるデータ・サイズです。 other/data_size フィールドは、external フィールドの別名です。file は、ディスクに保管されているデータのサイズ(バイト単位)です。
この計算に索引は含まれません。 disk_size フィールドは、file フィールドの別名です。 このサイズには、圧縮を待機しているデータが含まれます。 |
update_seq |
データベースの状態を表す判読不可のストリング。 このストリングを更新数のカウントに使用しないでください。 |
partitioned_indexes |
データベースがパーティション化されている場合にのみ表示される JSON オブジェクト。count は、パーティション索引の数です。indexes はパーティション索引のタイプをリストし、limit は許可されるパーティション索引の最大数を示します。 |
データベースの詳細を含む応答の例 (一部省略しています) を以下に示します。
{
"update_seq": "982...uUQ",
"db_name": "db",
"sizes": {
"file": 46114703224,
"external": 193164408719,
"active": 34961621142
},
"purge_seq": 0,
"other": {
"data_size": 193164408719
},
"doc_del_count": 5564,
"doc_count": 9818541,
"disk_size": 46114703224,
"disk_format_version": 6,
"compact_running": true,
"instance_start_time": "0",
"partitioned_indexes": {
"count": 7,
"indexes": {
"search": 1,
"view": 6
},
"limit": 10
}
}