12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.destroyAllDataPermanently = destroyAllDataPermanently;
- exports.resolvingPromise = resolvingPromise;
- exports.sleep = sleep;
- var _cache = _interopRequireDefault(require("./cache"));
- var _SchemaCache = _interopRequireDefault(require("./Adapters/Cache/SchemaCache"));
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
- /**
- * Destroys all data in the database
- * @param {boolean} fast set to true if it's ok to just drop objects and not indexes.
- */
- function destroyAllDataPermanently(fast) {
- if (!process.env.TESTING) {
- throw 'Only supported in test environment';
- }
- return Promise.all(Object.keys(_cache.default.cache).map(appId => {
- const app = _cache.default.get(appId);
- const deletePromises = [];
- if (app.cacheAdapter && app.cacheAdapter.clear) {
- deletePromises.push(app.cacheAdapter.clear());
- }
- if (app.databaseController) {
- deletePromises.push(app.databaseController.deleteEverything(fast));
- } else if (app.databaseAdapter) {
- _SchemaCache.default.clear();
- deletePromises.push(app.databaseAdapter.deleteAllClasses(fast));
- }
- return Promise.all(deletePromises);
- }));
- }
- function resolvingPromise() {
- let res;
- let rej;
- const promise = new Promise((resolve, reject) => {
- res = resolve;
- rej = reject;
- });
- promise.resolve = res;
- promise.reject = rej;
- return promise;
- }
- function sleep(ms) {
- return new Promise(resolve => setTimeout(resolve, ms));
- }
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJfY2FjaGUiLCJfaW50ZXJvcFJlcXVpcmVEZWZhdWx0IiwicmVxdWlyZSIsIl9TY2hlbWFDYWNoZSIsImUiLCJfX2VzTW9kdWxlIiwiZGVmYXVsdCIsImRlc3Ryb3lBbGxEYXRhUGVybWFuZW50bHkiLCJmYXN0IiwicHJvY2VzcyIsImVudiIsIlRFU1RJTkciLCJQcm9taXNlIiwiYWxsIiwiT2JqZWN0Iiwia2V5cyIsIkFwcENhY2hlIiwiY2FjaGUiLCJtY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