* Truncate all tables defined through the sequelize models. * This is done by calling `Model.truncate()` on each model. * * @param {object} [options] The options passed to Model.destroy in addition to truncate * @param {boolean|Function} [options.logging] A function that logs sql queries
(options)
| 833 | * {@link Model.truncate} for more information |
| 834 | */ |
| 835 | async truncate(options) { |
| 836 | const models = []; |
| 837 | |
| 838 | this.modelManager.forEachModel(model => { |
| 839 | if (model) { |
| 840 | models.push(model); |
| 841 | } |
| 842 | }, { reverse: false }); |
| 843 | |
| 844 | if (options && options.cascade) { |
| 845 | for (const model of models) await model.truncate(options); |
| 846 | } else { |
| 847 | await Promise.all(models.map(model => model.truncate(options))); |
| 848 | } |
| 849 | } |
| 850 | |
| 851 | /** |
| 852 | * Drop all tables defined through this sequelize instance. |
nothing calls this directly
no test coverage detected