Skip to content

table.truncate ​

Removes all rows from one of the model's tables, keeping its fields. To remove the table as well, use table.delete.

TIP

For more control, such as other column types, indexes or keys, manage tables with SQL instead. Run CREATE, ALTER and DROP TABLE statements with DatasourceClient's execute.

js
table.truncate(tableName)

Parameters ​

ParameterTypeDescription
tableNamestringThe table's name or id.

Returns ​

boolean

true if the table was emptied, false if it can't be found.

Examples ​

js
const removed = table.truncate("users");