Skip to content

Commit

Permalink
Export SeedService
Browse files Browse the repository at this point in the history
  • Loading branch information
AndriiSherman committed Dec 11, 2024
1 parent a4fb988 commit 8cf6a82
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 10 additions & 1 deletion drizzle-seed/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { BaseSQLiteDatabase, getTableConfig as getSqliteTableConfig, SQLiteTable

import type { AbstractGenerator } from './services/GeneratorsWrappers.ts';
import { generatorsFuncs } from './services/GeneratorsWrappers.ts';
import seedService from './services/SeedService.ts';
import { SeedService } from './services/SeedService.ts';
import type { DrizzleStudioObjectType, DrizzleStudioRelationType } from './types/drizzleStudio.ts';
import type { RefinementsType } from './types/seedService.ts';
import type { Column, Relation, RelationWithReferences, Table } from './types/tables.ts';
Expand Down Expand Up @@ -251,6 +251,8 @@ export async function seedForDrizzleStudio(
? schemasRefinements[schemaName]
: undefined;

const seedService = new SeedService();

const generatedTablesGenerators = seedService.generatePossibleGenerators(
sqlDialect,
tables,
Expand Down Expand Up @@ -489,6 +491,8 @@ const seedPostgres = async (
options: { count?: number; seed?: number } = {},
refinements?: RefinementsType,
) => {
const seedService = new SeedService();

const { tables, relations, tableRelations } = getPostgresInfo(schema);
const generatedTablesGenerators = seedService.generatePossibleGenerators(
'postgresql',
Expand Down Expand Up @@ -740,6 +744,8 @@ const seedMySql = async (
) => {
const { tables, relations, tableRelations } = getMySqlInfo(schema);

const seedService = new SeedService();

const generatedTablesGenerators = seedService.generatePossibleGenerators(
'mysql',
tables,
Expand Down Expand Up @@ -927,6 +933,8 @@ const seedSqlite = async (
) => {
const { tables, relations, tableRelations } = getSqliteInfo(schema);

const seedService = new SeedService();

const generatedTablesGenerators = seedService.generatePossibleGenerators(
'sqlite',
tables,
Expand Down Expand Up @@ -1072,3 +1080,4 @@ export { default as cities } from './datasets/cityNames.ts';
export { default as countries } from './datasets/countries.ts';
export { default as firstNames } from './datasets/firstNames.ts';
export { default as lastNames } from './datasets/lastNames.ts';
export { SeedService } from './services/SeedService.ts';
4 changes: 1 addition & 3 deletions drizzle-seed/src/services/SeedService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import {
} from './GeneratorsWrappers.ts';
import { equalSets, generateHashFromString } from './utils.ts';

class SeedService {
export class SeedService {
static readonly [entityKind]: string = 'SeedService';

private defaultCountForTable = 10;
Expand Down Expand Up @@ -1470,5 +1470,3 @@ class SeedService {
}
};
}

export default new SeedService();

0 comments on commit 8cf6a82

Please sign in to comment.