Skip to content

Commit

Permalink
chore: lazy assign schema properties to class functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinigami92 committed Jan 12, 2022
1 parent 5f6bb46 commit 42b112b
Showing 1 changed file with 22 additions and 28 deletions.
50 changes: 22 additions & 28 deletions src/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,28 @@ export class Database {
}
this[name] = this[name].bind(this);
}

// TODO @Shinigami92 2022-01-11: We should find a better strategy as assigning this property to a function
// @ts-expect-error
this.column.schema = {
description: 'Generates a column name.',
sampleResults: ['id', 'title', 'createdAt'],
};
// @ts-expect-error
this.type.schema = {
description: 'Generates a column type.',
sampleResults: ['byte', 'int', 'varchar', 'timestamp'],
};
// @ts-expect-error
this.collation.schema = {
description: 'Generates a collation.',
sampleResults: ['utf8_unicode_ci', 'utf8_bin'],
};
// @ts-expect-error
this.engine.schema = {
description: 'Generates a storage engine.',
sampleResults: ['MyISAM', 'InnoDB'],
};
}

/**
Expand All @@ -22,13 +44,6 @@ export class Database {
);
}

readonly column = {
schema: {
description: 'Generates a column name.',
sampleResults: ['id', 'title', 'createdAt'],
},
};

/**
* type
*
Expand All @@ -38,13 +53,6 @@ export class Database {
return this.faker.random.arrayElement(this.faker.definitions.database.type);
}

readonly type = {
schema: {
description: 'Generates a column type.',
sampleResults: ['byte', 'int', 'varchar', 'timestamp'],
},
};

/**
* collation
*
Expand All @@ -56,13 +64,6 @@ export class Database {
);
}

readonly collation = {
schema: {
description: 'Generates a collation.',
sampleResults: ['utf8_unicode_ci', 'utf8_bin'],
},
};

/**
* engine
*
Expand All @@ -73,11 +74,4 @@ export class Database {
this.faker.definitions.database.engine
);
}

readonly engine = {
schema: {
description: 'Generates a storage engine.',
sampleResults: ['MyISAM', 'InnoDB'],
},
};
}

0 comments on commit 42b112b

Please sign in to comment.