Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: improve database jsdocs #424

Merged
merged 3 commits into from
Feb 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 15 additions & 30 deletions src/database.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import type { Faker } from '.';

/**
* Module to generate database related entries.
*/
export class Database {
constructor(private readonly faker: Faker) {
// Bind `this` so namespaced is working correctly
Expand All @@ -9,34 +12,13 @@ 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'],
};
}

/**
* column
* Returns a random database column name.
*
* @method faker.database.column
* @example
* faker.database.column() // 'createdAt'
*/
column(): string {
return this.faker.random.arrayElement(
Expand All @@ -45,18 +27,20 @@ export class Database {
}

/**
* type
* Returns a random database column type.
*
* @method faker.database.type
* @example
* faker.database.type() // 'timestamp'
*/
type(): string {
return this.faker.random.arrayElement(this.faker.definitions.database.type);
}

/**
* collation
* Returns a random database collation.
*
* @method faker.database.collation
* @example
* faker.database.collation() // 'utf8_unicode_ci'
*/
collation(): string {
return this.faker.random.arrayElement(
Expand All @@ -65,9 +49,10 @@ export class Database {
}

/**
* engine
* Returns a random database engine.
*
* @method faker.database.engine
* @example
* faker.database.engine() // 'ARCHIVE'
*/
engine(): string {
return this.faker.random.arrayElement(
Expand Down