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);
}
Parameter:
Gibt zurück:
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);
}
Parameter:
Gibt zurück:
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);
}
Parameter:
Gibt zurück:
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);
}
Parameter:
Gibt zurück:
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);
}
Parameter:
Gibt zurück:
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);
}
Parameter:
Gibt zurück:
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);
Parameter:
Gibt zurück:
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.
Parameter:
Gibt zurück:
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
);
Parameter:
Gibt zurück:
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.
Parameter:
Gibt zurück:
createUser
public CosmosUserResponse createUser(CosmosUserProperties userProperties)
Erstellen eines Cosmos-Benutzers.
CosmosUserProperties userProperties = new CosmosUserProperties();
userProperties.setId(userId);
cosmosDatabase.createUser(userProperties);
Parameter:
Gibt zurück:
delete
public CosmosDatabaseResponse delete()
Löscht die aktuelle Cosmos-Datenbank.
CosmosDatabase cosmosDatabase = cosmosClient
.getDatabase("<YOUR DATABASE NAME>");
CosmosDatabaseResponse deleteResponse = cosmosDatabase.delete();
Gibt zurück:
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();
Parameter:
Gibt zurück:
getClientEncryptionKey
public CosmosClientEncryptionKey getClientEncryptionKey(String id)
Ruft ein CosmosClientEncryptionKey-Objekt ab, ohne einen Dienstaufruf auszuführen
Parameter:
Gibt zurück:
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.
Parameter:
Gibt zurück:
getId
public String getId()
Rufen Sie die ID der Cosmos-Datenbank ab.
Gibt zurück:
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.
Parameter:
Gibt zurück:
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);
});
Parameter:
Gibt zurück:
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);
});
Parameter:
Gibt zurück:
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);
});
Parameter:
Gibt zurück:
queryContainers
public CosmosPagedIterable
Abfragecontainer-Iterator.
CosmosPagedIterable<CosmosContainerProperties> cosmosContainersList =
cosmosDatabase.queryContainers("SELECT * FROM DB_NAME");
cosmosContainersList.forEach(cosmosContainerProperties -> {
System.out.println(cosmosContainerProperties);
});
Parameter:
Gibt zurück:
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);
});
Parameter:
Gibt zurück:
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);
});
Parameter:
Gibt zurück:
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);
});
Parameter:
Gibt zurück:
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);
});
Parameter:
Gibt zurück:
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();
Gibt zurück:
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();
Parameter:
Gibt zurück:
readAllClientEncryptionKeys
public CosmosPagedIterable
Liest alle Cosmos-Clientverschlüsselungsschlüssel in einer Datenbank.
CosmosPagedIterable<CosmosClientEncryptionKeyProperties> clientEncryptionKeys =
cosmosDatabase.readAllClientEncryptionKeys();
clientEncryptionKeys.forEach(encryptionKeyProperties ->
System.out.println(clientEncryptionKeys)
);
Gibt zurück:
readAllContainers
public CosmosPagedIterable
Lesen Sie alle Container in der aktuellen Datenbank.
CosmosPagedIterable<CosmosContainerProperties> cosmosContainersList =
cosmosDatabase.readAllContainers();
cosmosContainersList.forEach(cosmosContainerProperties -> {
System.out.println(cosmosContainerProperties);
});
Gibt zurück:
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);
});
Gibt zurück:
readThroughput
public ThroughputResponse readThroughput()
Ruft den Durchsatz der aktuellen Datenbank ab.
ThroughputResponse throughputResponse = cosmosDatabase.readThroughput();
System.out.println(throughputResponse);
Gibt zurück:
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);
Parameter:
Gibt zurück:
upsertUser
public CosmosUserResponse upsertUser(CosmosUserProperties userProperties)
Upsert einen Cosmos-Benutzer.
CosmosUserProperties userProperties = new CosmosUserProperties();
userProperties.setId(userId);
cosmosDatabase.upsertUser(userProperties);
Parameter:
Gibt zurück:
Gilt für:
Azure SDK for Java