CosmosDatabase Klasse
- java.
lang. Object - com.
azure. cosmos. CosmosDatabase
- com.
public class CosmosDatabase
Ausführen von Lese- und Löschdatenbanken, Aktualisieren des Datenbankdurchsatzes und Ausführen von Vorgängen für untergeordnete Ressourcen auf synchrone Weise
Methodenzusammenfassung
Geerbte Methoden von java.lang.Object
Details zur Methode
createContainer
public CosmosContainerResponse createContainer(CosmosContainerProperties containerProperties)
Erstellt einen Cosmos-Container.
CosmosContainerProperties containerProperties =
new CosmosContainerProperties(containerId, partitionKeyDefinition);
try {
CosmosContainerResponse container = cosmosDatabase.createContainer(containerProperties);
} catch (CosmosException ce) {
System.out.println("Failed to create container: " + ce);
}
Parameters:
Returns:
createContainer
public CosmosContainerResponse createContainer(CosmosContainerProperties containerProperties, CosmosContainerRequestOptions options)
Erstellt einen Cosmos-Container, während zusätzliche Anforderungsoptionen übergeben werden.
CosmosContainerProperties containerProperties =
new CosmosContainerProperties(containerId, partitionKeyDefinition);
try {
CosmosContainerResponse container = cosmosDatabase.createContainer(containerProperties);
} catch (CosmosException ce) {
System.out.println("Failed to create container: " + ce);
}
Parameters:
Returns:
createContainer
public CosmosContainerResponse createContainer(CosmosContainerProperties containerProperties, ThroughputProperties throughputProperties)
Erstellt einen Cosmos-Container mit benutzerdefinierter Durchsatzeinstellung.
CosmosContainerProperties containerProperties =
new CosmosContainerProperties(containerId, partitionKeyDefinition);
ThroughputProperties throughputProperties =
ThroughputProperties.createAutoscaledThroughput(autoScaleMaxThroughput);
try {
CosmosContainerResponse container = cosmosDatabase.createContainer(
containerProperties,
throughputProperties
);
} catch (CosmosException ce) {
System.out.println("Failed to create container: " + ce);
}
Parameters:
Returns:
createContainer
public CosmosContainerResponse createContainer(CosmosContainerProperties containerProperties, ThroughputProperties throughputProperties, CosmosContainerRequestOptions options)
Erstellt einen Cosmos-Container.
CosmosContainerProperties containerProperties =
new CosmosContainerProperties(containerId, partitionKeyDefinition);
ThroughputProperties throughputProperties =
ThroughputProperties.createAutoscaledThroughput(autoScaleMaxThroughput);
try {
CosmosContainerResponse container = cosmosDatabase.createContainer(
containerProperties,
throughputProperties
);
} catch (CosmosException ce) {
System.out.println("Failed to create container: " + ce);
}
Parameters:
Returns:
createContainer
public CosmosContainerResponse createContainer(String id, String partitionKeyPath)
Erstellen Sie einen Cosmos-Container.
ThroughputProperties throughputProperties =
ThroughputProperties.createAutoscaledThroughput(autoscaledThroughput);
try {
CosmosContainerResponse container = cosmosDatabase.createContainer(
containerId,
partitionKeyPath,
throughputProperties
);
} catch (CosmosException ce) {
System.out.println("Failed to create container: " + ce);
}
Parameters:
Returns:
createContainer
public CosmosContainerResponse createContainer(String id, String partitionKeyPath, ThroughputProperties throughputProperties)
Erstellen Sie einen Cosmos-Container.
ThroughputProperties throughputProperties =
ThroughputProperties.createAutoscaledThroughput(autoscaledThroughput);
try {
CosmosContainerResponse container = cosmosDatabase.createContainer(
containerId,
partitionKeyPath,
throughputProperties
);
} catch (CosmosException ce) {
System.out.println("Failed to create container: " + ce);
}
Parameters:
Returns:
createContainerIfNotExists
public CosmosContainerResponse createContainerIfNotExists(CosmosContainerProperties containerProperties)
Erstellen Sie einen Container, wenn einer, der der ID im Eigenschaftenobjekt entspricht, nicht vorhanden ist.
CosmosContainerProperties containerProperties =
new CosmosContainerProperties(containerId, partitionKeyDefinition);
CosmosContainerResponse container = cosmosDatabase.createContainerIfNotExists(containerProperties);
Parameters:
Returns:
createContainerIfNotExists
public CosmosContainerResponse createContainerIfNotExists(CosmosContainerProperties containerProperties, ThroughputProperties throughputProperties)
Erstellt einen Cosmos-Container, wenn einer, der der ID im Eigenschaftenobjekt entspricht, nicht vorhanden ist.
CosmosContainerProperties containerProperties =
new CosmosContainerProperties(containerId, partitionKeyDefinition);
ThroughputProperties throughputProperties =
ThroughputProperties.createAutoscaledThroughput(autoScaleMaxThroughput);
CosmosContainerResponse container = cosmosDatabase.createContainerIfNotExists(
containerProperties,
throughputProperties
);
Die Durchsatzeigenschaften werden nur verwendet, wenn der angegebene Container nicht vorhanden ist und daher ein neuer Container erstellt wird.
Parameters:
Returns:
createContainerIfNotExists
public CosmosContainerResponse createContainerIfNotExists(String id, String partitionKeyPath)
Erstellt einen Cosmos-Container, wenn einer, der der ID entspricht, nicht vorhanden ist.
ThroughputProperties throughputProperties =
ThroughputProperties.createAutoscaledThroughput(autoscaledThroughput);
CosmosContainerResponse container = cosmosDatabase.createContainerIfNotExists(
containerId,
partitionKeyPath,
throughputProperties
);
Parameters:
Returns:
createContainerIfNotExists
public CosmosContainerResponse createContainerIfNotExists(String id, String partitionKeyPath, ThroughputProperties throughputProperties)
Erstellt einen Cosmos-Container, wenn einer, der der ID entspricht, nicht vorhanden ist.
ThroughputProperties throughputProperties =
ThroughputProperties.createAutoscaledThroughput(autoscaledThroughput);
CosmosContainerResponse container = cosmosDatabase.createContainerIfNotExists(
containerId,
partitionKeyPath,
throughputProperties
);
Die Durchsatzeigenschaften werden nur verwendet, wenn der angegebene Container nicht vorhanden ist und daher ein neuer Container erstellt wird.
Parameters:
Returns:
createUser
public CosmosUserResponse createUser(CosmosUserProperties userProperties)
Erstellen eines Cosmos-Benutzers.
CosmosUserProperties userProperties = new CosmosUserProperties();
userProperties.setId(userId);
cosmosDatabase.createUser(userProperties);
Parameters:
Returns:
delete
public CosmosDatabaseResponse delete()
Löscht die aktuelle Cosmos-Datenbank.
CosmosDatabase cosmosDatabase = cosmosClient
.getDatabase("<YOUR DATABASE NAME>");
CosmosDatabaseResponse deleteResponse = cosmosDatabase.delete();
Returns:
delete
public CosmosDatabaseResponse delete(CosmosDatabaseRequestOptions options)
Löschen Sie die aktuelle Cosmos-Datenbank, während Sie zusätzliche Anforderungsoptionen angeben.
CosmosDatabase cosmosDatabase = cosmosClient
.getDatabase("<YOUR DATABASE NAME>");
CosmosDatabaseResponse deleteResponse = cosmosDatabase.delete();
Parameters:
Returns:
getClientEncryptionKey
public CosmosClientEncryptionKey getClientEncryptionKey(String id)
Ruft ein CosmosClientEncryptionKey-Objekt ab, ohne einen Dienstaufruf auszuführen
Parameters:
Returns:
getContainer
public CosmosContainer getContainer(String id)
Ruft einen Cosmos-Container instance ab, ohne einen Dienstaufruf zu tätigen.
Um das tatsächliche Objekt abzurufen, muss zuerst ein Lesevorgang ausgeführt werden.
Parameters:
Returns:
getId
public String getId()
Rufen Sie die ID der Cosmos-Datenbank ab.
Returns:
getUser
public CosmosUser getUser(String id)
Ruft einen Cosmos-Benutzer instance ab, ohne einen Dienstaufruf zu tätigen.
Um das tatsächliche Objekt abzurufen, muss zuerst ein Lesevorgang ausgeführt werden.
Parameters:
Returns:
queryContainers
public CosmosPagedIterable
Abfragen von Containern in der aktuellen Datenbank.
CosmosPagedIterable<CosmosContainerProperties> cosmosContainersList =
cosmosDatabase.queryContainers("SELECT * FROM DB_NAME");
cosmosContainersList.forEach(cosmosContainerProperties -> {
System.out.println(cosmosContainerProperties);
});
Parameters:
Returns:
queryContainers
public CosmosPagedIterable
Abfragen von Containern in der aktuellen Datenbank.
CosmosPagedIterable<CosmosContainerProperties> cosmosContainersList =
cosmosDatabase.queryContainers("SELECT * FROM DB_NAME");
cosmosContainersList.forEach(cosmosContainerProperties -> {
System.out.println(cosmosContainerProperties);
});
Parameters:
Returns:
queryContainers
public CosmosPagedIterable
Abfragen von Containern in der aktuellen Datenbank.
CosmosPagedIterable<CosmosContainerProperties> cosmosContainersList =
cosmosDatabase.queryContainers("SELECT * FROM DB_NAME");
cosmosContainersList.forEach(cosmosContainerProperties -> {
System.out.println(cosmosContainerProperties);
});
Parameters:
Returns:
queryContainers
public CosmosPagedIterable
Abfragecontainer-Iterator.
CosmosPagedIterable<CosmosContainerProperties> cosmosContainersList =
cosmosDatabase.queryContainers("SELECT * FROM DB_NAME");
cosmosContainersList.forEach(cosmosContainerProperties -> {
System.out.println(cosmosContainerProperties);
});
Parameters:
Returns:
queryUsers
public CosmosPagedIterable
Fragen Sie alle Cosmos-Benutzer nach der aktuellen Datenbank ab.
CosmosPagedIterable<CosmosUserProperties> userPropertiesList =
cosmosDatabase.queryUsers("SELECT * FROM DB_NAME");
userPropertiesList.forEach(userProperties -> {
System.out.println(userProperties);
});
Parameters:
Returns:
queryUsers
public CosmosPagedIterable
Fragen Sie alle Cosmos-Benutzer nach der aktuellen Datenbank ab.
CosmosPagedIterable<CosmosUserProperties> userPropertiesList =
cosmosDatabase.queryUsers("SELECT * FROM DB_NAME");
userPropertiesList.forEach(userProperties -> {
System.out.println(userProperties);
});
Parameters:
Returns:
queryUsers
public CosmosPagedIterable
Fragen Sie alle Cosmos-Benutzer nach der aktuellen Datenbank ab.
CosmosPagedIterable<CosmosUserProperties> userPropertiesList =
cosmosDatabase.queryUsers("SELECT * FROM DB_NAME");
userPropertiesList.forEach(userProperties -> {
System.out.println(userProperties);
});
Parameters:
Returns:
queryUsers
public CosmosPagedIterable
Fragen Sie alle Cosmos-Benutzer nach der aktuellen Datenbank ab.
CosmosPagedIterable<CosmosUserProperties> userPropertiesList =
cosmosDatabase.queryUsers("SELECT * FROM DB_NAME");
userPropertiesList.forEach(userProperties -> {
System.out.println(userProperties);
});
Parameters:
Returns:
read
public CosmosDatabaseResponse read()
Liest die aktuelle Cosmos-Datenbank. Ruft die Details und Eigenschaften einer Datenbank basierend auf ihrem eindeutigen Bezeichner ab.
CosmosDatabase cosmosDatabase = cosmosClient
.getDatabase("<YOUR DATABASE NAME>");
CosmosDatabaseResponse readResponse = cosmosDatabase.read();
Returns:
read
public CosmosDatabaseResponse read(CosmosDatabaseRequestOptions options)
Liest die aktuelle Cosmos-Datenbank, während zusätzliche Anforderungsoptionen angegeben werden. Ruft die Details und Eigenschaften einer Datenbank basierend auf ihrem eindeutigen Bezeichner ab.
CosmosDatabase cosmosDatabase = cosmosClient
.getDatabase("<YOUR DATABASE NAME>");
CosmosDatabaseResponse readResponse = cosmosDatabase.read();
Parameters:
Returns:
readAllClientEncryptionKeys
public CosmosPagedIterable
Liest alle Cosmos-Clientverschlüsselungsschlüssel in einer Datenbank.
CosmosPagedIterable<CosmosClientEncryptionKeyProperties> clientEncryptionKeys =
cosmosDatabase.readAllClientEncryptionKeys();
clientEncryptionKeys.forEach(encryptionKeyProperties ->
System.out.println(clientEncryptionKeys)
);
Returns:
readAllContainers
public CosmosPagedIterable
Lesen Sie alle Container in der aktuellen Datenbank.
CosmosPagedIterable<CosmosContainerProperties> cosmosContainersList =
cosmosDatabase.readAllContainers();
cosmosContainersList.forEach(cosmosContainerProperties -> {
System.out.println(cosmosContainerProperties);
});
Returns:
readAllUsers
public CosmosPagedIterable
Lesen Sie alle Cosmos-Benutzer für die aktuelle Datenbank.
CosmosPagedIterable<CosmosUserProperties> cosmosUserProperties = cosmosDatabase.readAllUsers();
cosmosUserProperties.forEach(userProperties -> {
System.out.println(userProperties);
});
Returns:
readThroughput
public ThroughputResponse readThroughput()
Ruft den Durchsatz der aktuellen Datenbank ab.
ThroughputResponse throughputResponse = cosmosDatabase.readThroughput();
System.out.println(throughputResponse);
Returns:
replaceThroughput
public ThroughputResponse replaceThroughput(ThroughputProperties throughputProperties)
Legt den Durchsatz der aktuellen Datenbank fest.
ThroughputProperties throughputProperties = ThroughputProperties
.createAutoscaledThroughput(autoScaleMaxThroughput);
ThroughputResponse throughputResponse = cosmosDatabase.replaceThroughput(throughputProperties);
System.out.println(throughputResponse);
Parameters:
Returns:
upsertUser
public CosmosUserResponse upsertUser(CosmosUserProperties userProperties)
Upsert einen Cosmos-Benutzer.
CosmosUserProperties userProperties = new CosmosUserProperties();
userProperties.setId(userId);
cosmosDatabase.upsertUser(userProperties);
Parameters:
Returns:
Gilt für:
Azure SDK for Java
Feedback
https://aka.ms/ContentUserFeedback.
Bald verfügbar: Im Laufe des Jahres 2024 werden wir GitHub-Issues stufenweise als Feedbackmechanismus für Inhalte abbauen und durch ein neues Feedbacksystem ersetzen. Weitere Informationen finden Sie unterFeedback senden und anzeigen für