Truncate table [PostgreSQL MySQL]
API
For the full list of supported methods, see TruncateTableQuery
open in new window.
1. db.NewTruncateTable().
3. Model(&strct).
5. Table("table1"). // quotes table names
6. TableExpr("table1"). // arbitrary unsafe expression
7. ModelTableExpr("table1"). // overrides model table name
9. ContinueIdentity().
10. Cascade().
11. Restrict().
13. Exec(ctx)
Example
To drop a table:
1. _, err := db.NewTruncateTable().Model((*Book)(nil)).Exec(ctx)
2. if err != nil {
3. panic(err)
4. }
