Skip to main content

Document Database (NoSQL)

v3.0.0+

The tcb db nosql command has been available since v3.0.0.

The tcb db nosql command is used to execute native commands and perform data restore operations on the CloudBase Document Database (MongoDB).

Prerequisites

Need to first enable the Document Database service in the CloudBase console.

tcb db nosql execute

Execute native MongoDB commands (RunCommands API).

tcb db nosql execute --command '<json>' [options]

Parameters

ParameterDescriptionRequired
-c, --command <json>MgoCommands JSON
--tag <tag>Instance Tag (used to distinguish between multiple instances in the same environment)
--instanceId <id>MongoConnector Instance ID
--databaseName <name>MongoConnector Database Name
-e, --env-id <envId>Environment ID

API documentation: RunCommands · MgoCommandParam Data Structure

Example

# Query the first 5 items of the users collection.
tcb db nosql execute \
--command '{"find": "users", "limit": 5}' \
-e my-env-id

# Execute the specified instance
tcb db nosql execute \
--command '{"count": "orders", "query": {"status": "paid"}}' \
--instanceId inst-xxx \
-e my-env-id

Data Restoration

Data Restoration allows the Document Database to be restored to a specified historical point in time or backup snapshot.

tcb db nosql restore-time

Query the current restorable time range.

tcb db nosql restore-time [options]

tcb db nosql restore-tables

Query the list of restorable collections at the specified time point.

tcb db nosql restore-tables --time <time> [--filters <collections>] [options]
ParameterDescription
--time <time>Target restore time (e.g. 2026-03-10 14:30:00)
--filters <collections>Filter conditions, comma-separated list of collection names

tcb db nosql restore

Perform instance table restoration.

tcb db nosql restore --time <time> --tables '<json>' [options]
ParameterDescriptionRequired
--time <time>Target restore time
--tables <json>Table mapping JSON array for restoration
--instanceId <id>MongoConnector Instance ID
--databaseName <name>MongoConnector Database Name

--tables format:

[{"OldTableName": "original collection name", "NewTableName": "new collection name (restore target)"}]

tcb db nosql restore-task

Query restore task progress.

tcb db nosql restore-task [options]

Complete Restore Example

# 1. View the restorable time range
tcb db nosql restore-time -e my-env-id

# 2. View restorable collections at this time point
tcb db nosql restore-tables --time "2026-03-10 14:00:00" -e my-env-id

# 3. Perform restore (overwrite to new collection name)
tcb db nosql restore \
--time "2026-03-10 14:00:00" \
--tables '[{"OldTableName":"orders","NewTableName":"orders_restored"}]' \
-e my-env-id

# 4. Query restore task progress
tcb db nosql restore-task -e my-env-id