Drop a collection
Deletes a collection from a database and erases all data stored in the collection.
Ready to write code? See the examples for this method to get started. If you are new to the Data API, check out the quickstart. |
Result
-
Python
-
TypeScript
-
Java
-
curl
Deletes the specified collection from the database and erases all data stored in the collection.
The method returns None
upon successful completion.
Deletes the specified collection from the database and erases all data stored in the collection.
Returns a promise that resolves once the operation completes.
Deletes the specified collection from the database and erases all data stored in the collection.
Does not return anything.
Deletes the specified collection from the database and erases all data stored in the collection.
If the command succeeds, the response indicates the success.
Example response:
{
"status": {
"ok": 1
}
}
Parameters
-
Python
-
TypeScript
-
Java
-
curl
Use the drop_collection
method, which belongs to the astrapy.Database
class.
Method signature
drop_collection(
name: str,
*,
keyspace: str,
collection_admin_timeout_ms: int,
request_timeout_ms: int,
timeout_ms: int,
) -> None:
The database’s drop_collection
method is equivalent to the collection’s own collection.drop()
method.
Name | Type | Summary |
---|---|---|
|
|
The name of the collection to drop. |
|
|
Optional. The keyspace containing the collection. Default: The database’s working keyspace. |
|
|
A timeout, in milliseconds, for the underlying HTTP request.
If not provided, the |
Use the dropCollection
method, which belongs to the Db
class.
Method signature
async dropCollection(
name: string,
options?: {
keyspace?: string,
timeout?: number | TimeoutDescriptor,
}
): void
Name | Type | Summary |
---|---|---|
|
|
The name of the collection to drop. |
|
Optional.
The options for this operation. See Properties of |
Name | Type | Summary |
---|---|---|
|
Optional. The keyspace containing the collection. Default: The database’s working keyspace. |
|
|
|
Optional. The timeout(s) to apply to this method.
You can specify Details about the
|
Use the dropCollection
method, which belongs to the com.datastax.astra.client.Database
class.
Method signature
void dropCollection(String collectionName)
void dropCollection(
String collectionName,
DropCollectionOptions options
)
Name | Type | Summary |
---|---|---|
|
|
The name of the collection to drop. |
|
Optional. The options for this operation, including the keyspace and timeouts. |
Use the deleteCollection
command.
Command signature
curl -sS -L -X POST "API_ENDPOINT/api/json/v1/KEYSPACE_NAME" \
--header "Token: APPLICATION_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"deleteCollection": {
"name": "COLLECTION_NAME"
}
}'
Name | Type | Summary |
---|---|---|
|
|
The name of the collection to delete. |
Examples
The following examples demonstrate how to drop a collection.
-
Python
-
TypeScript
-
Java
-
curl
from astrapy import DataAPIClient
# Get a database
client = DataAPIClient()
database = client.get_database(
"API_ENDPOINT",
token="APPLICATION_TOKEN",
)
# Drop a collection
database.drop_collection("COLLECTION_NAME")
import { DataAPIClient } from "@datastax/astra-db-ts";
// Get a database
const client = new DataAPIClient("APPLICATION_TOKEN");
const database = client.db("API_ENDPOINT");
// Drop a collection
(async function () {
await database.dropCollection("COLLECTION_NAME");
})();
import com.datastax.astra.client.DataAPIClient;
import com.datastax.astra.client.databases.Database;
public class Example {
public static void main(String[] args) {
// Get a database
Database database = new DataAPIClient("APPLICATION_TOKEN").getDatabase("API_ENDPOINT");
// Drop a collection
database.dropCollection("COLLECTION_NAME");
}
}
curl -sS -L -X POST "API_ENDPOINT/api/json/v1/KEYSPACE_NAME" \
--header "Token: APPLICATION_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"deleteCollection": {
"name": "COLLECTION_NAME"
}
}'
Client reference
-
Python
-
TypeScript
-
Java
-
curl
For more information, see the client reference.
For more information, see the client reference.
For more information, see the client reference.
Client reference documentation is not applicable for HTTP.