async dropAndCreate(tableName) { const dialect = this.sequelize.getDialect(); const fixtureFilename = path.join(__dirname, `../test-fixtures/${dialect}/${tableName}.sql`); const fixtureFileContent = await fs.readFileSync(fixtureFilename, 'utf8'); await this.drop(tableName, dialect); return this.sequelize.query(fixtureFileContent); }
deleteAllClasses(fast: boolean) { return storageAdapterAllCollections(this).then((collections) => Promise.all( collections.map((collection) => fast ? collection.deleteMany({}) : collection.drop() ) ) ); }
/* * Helper to parse a command into useful metadataz */ const parseCmd = meta => _.merge({}, meta, { bin: _.trimEnd(path.basename(_.first(meta._), '"')), cmd: meta._[1], args: _.drop(meta._, 2), })
export function parseDomainAgainstTldList( domainFragment, tldList ) { if ( ! domainFragment ) { return ''; } if ( tldList[ domainFragment ] !== undefined ) { return domainFragment; } const parts = split( domainFragment, '.' ); const suffix = join( drop( parts ), '.' ); return parseDomainAgainstTldList( suffix, tldList ); }
drop() { return this._mongoCollection.drop(); }
// Drops a collection. Resolves with true if it was a Parse Schema (eg. _User, Custom, etc.) // and resolves with false if it wasn't (eg. a join table). Rejects if deletion was impossible. deleteClass(className) { return this._adaptiveCollection(className).then(collection => collection.drop()).catch(error => { // 'ns not found' means collection was already gone. Ignore deletion attempt. if (error.message == 'ns not found') { return; } throw error; }) // We've dropped the collection, now remove the _SCHEMA document .then(() => this._schemaCollection()).then(schemaCollection => schemaCollection.findAndDeleteSchema(className)).catch(err => this.handleError(err)); }
/* * Helper to map the cwd on the host to the one in the container */ const getContainerPath = appRoot => { // Break up our app root and cwd so we can get a diff const cwd = process.cwd().split(path.sep); const dir = _.drop(cwd, appRoot.split(path.sep).length); // Add our in-container app root // this will always be /app dir.unshift('/app'); // Return the directory return dir.join('/'); }
async dropAllCollections() { const collections = await this.db.listCollections().toArray(); return Promise.all(collections.map(({ name }) => this.db.collection(name).drop())); }
prepareTableNamesToTables(tableNames) { this.tableNamesToTables = R.pipe( R.unnest, R.groupBy(n => n[0]), R.map(groupedNameToDef => groupedNameToDef.map(nameToDef => nameToDef[1])) )( tableNames.map(tableName => { const [schema, table] = this.parseTableName(tableName); const tableDefinition = this.resolveTableDefinition(tableName); const definition = { schema, table, tableDefinition, tableName }; const tableizeName = inflection.tableize(table); const parts = tableizeName.split('_'); const tableNamesFromParts = R.range(0, parts.length - 1).map(toDrop => inflection.tableize(R.drop(toDrop, parts).join('_'))); const names = R.uniq([table, tableizeName].concat(tableNamesFromParts)); return names.map(n => [n, definition]); }) ); }
cursor = ctx.start.start; if (ctx.children[0].getText() === originalAlias) { const withoutFirst = R.drop(1, ctx.children); result += [tableAlias].concat(withoutFirst.map(c => c.getText())).join(''); cursor = ctx.stop.stop + 1;
async dropAllTables() { await this.sequelize.drop(); }
export function parseDomainAgainstTldList( domainFragment, tldList ) { if ( ! domainFragment ) { return ''; } if ( tldList[ domainFragment ] !== undefined ) { return domainFragment; } const parts = split( domainFragment, '.' ); const suffix = join( drop( parts ), '.' ); return parseDomainAgainstTldList( suffix, tldList ); }
deleteAllClasses(fast) { return storageAdapterAllCollections(this).then(collections => Promise.all(collections.map(collection => fast ? collection.deleteMany({}) : collection.drop()))); }
drop() { return this._mongoCollection.drop(); }
// Drops a collection. Resolves with true if it was a Parse Schema (eg. _User, Custom, etc.) // and resolves with false if it wasn't (eg. a join table). Rejects if deletion was impossible. deleteClass(className: string) { return ( this._adaptiveCollection(className) .then((collection) => collection.drop()) .catch((error) => { // 'ns not found' means collection was already gone. Ignore deletion attempt. if (error.message == 'ns not found') { return; } throw error; }) // We've dropped the collection, now remove the _SCHEMA document .then(() => this._schemaCollection()) .then((schemaCollection) => schemaCollection.findAndDeleteSchema(className) ) .catch((err) => this.handleError(err)) ); }