Synchronization model definition
To enhance developers' code writing experience, cloud data models can be synchronized to local type definition files, enabling intelligent type hints and checks in the code editor. The post-synchronization effect is as follows:
Data Model Intelligent Hints

Field Intelligent Hints

Synchronization Process
Select any of the following methods to synchronize the data model definition:
Note:
- For WeChat Mini Programs, run the command in the same directory as the
app.jsonfile.- For WeChat Cloud Development Cloud Functions, run the command in the
cloudfunctions/<functions folder>directory.- First run requires specifying the environment ID parameter
--envId=<envId>, and subsequent runs do not require specifying it again.- Running tcb requires login. For users of WeChat Cloud Development, please select the [Mini Program Official Account] login method during sign-in.

Method 1: Run the tcb command directly with npx
This method is only applicable when
tcbis not installed locally. Iftcbis already installed locally, please use Method 2
Go to the project directory (refer to the notes for directory location), then execute the following command:
npx --package=@cloudbase/cli tcb sync-model-dts --envId=<envId>
Method 2: Install the tcb command-line tool
If
tcbis not installed locally or the installed version oftcbis <2.4, execute the following command to install or upgrade it.
npm i @cloudbase/cli -g
Go to the project directory (refer to the notes for directory location), then execute the following command:
tcb sync-model-dts --envId=<envId>
Common Issues and Solutions
Issue: No model hints in the code editor
- Ensure the
@cloudbase/wx-cloud-client-sdkmodule is properly installed. - Ensure the
tsconfig.jsonfile is configured correctly:
{
"compilerOptions": {
"allowJs": true
}
}