MCPcopy
hub / github.com/sequelize/sequelize / truncate

Method truncate

lib/sequelize.js:835–849  ·  lib/sequelize.js::Sequelize.truncate

* 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)

Source from the content-addressed store, hash-verified

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.

Callers

nothing calls this directly

Calls 2

forEachModelMethod · 0.80
allMethod · 0.80

Tested by

no test coverage detected