MCPcopy Create free account
hub / github.com/mikro-orm/mikro-orm / prune

Method prune

packages/sql/src/schema/DatabaseSchema.ts:669–698  ·  view source on GitHub ↗
(schema: string | undefined, wildcardSchemaTables: string[])

Source from the content-addressed store, hash-verified

667 }
668
669 prune(schema: string | undefined, wildcardSchemaTables: string[]): void {
670 const hasWildcardSchema = wildcardSchemaTables.length > 0;
671 this.#tables = this.#tables.filter(table => {
672 return (
673 (!schema && !hasWildcardSchema) || // no schema specified and we don't have any multi-schema entity
674 table.schema === schema || // specified schema matches the table's one
675 (!schema && !wildcardSchemaTables.includes(table.name))
676 ); // no schema specified and the table has fixed one provided
677 });
678
679 this.#views = this.#views.filter(view => {
680 /* v8 ignore next */
681 return (
682 (!schema && !hasWildcardSchema) ||
683 view.schema === schema ||
684 (!schema && !wildcardSchemaTables.includes(view.name))
685 );
686 });
687
688 // remove namespaces of ignored tables and views
689 for (const ns of this.#namespaces) {
690 if (
691 !this.#tables.some(t => t.schema === ns) &&
692 !this.#views.some(v => v.schema === ns) &&
693 !Object.values(this.#nativeEnums).some(e => e.schema === ns)
694 ) {
695 this.#namespaces.delete(ns);
696 }
697 }
698 }
699}

Callers 2

updateMethod · 0.80

Calls 3

filterMethod · 0.80
deleteMethod · 0.65
valuesMethod · 0.45

Tested by

no test coverage detected