aboutsummaryrefslogtreecommitdiff
path: root/src/database.ts
diff options
context:
space:
mode:
authorST-DDT <[email protected]>2022-02-06 11:24:05 +0100
committerGitHub <[email protected]>2022-02-06 11:24:05 +0100
commitc0b4e976d068294a34a38df96113c61285ef53d1 (patch)
tree1f8836aee2d827910d743fc4ca0869ab25d16e21 /src/database.ts
parent7d9ae2f580a0fbe50bebe4660b01e14755c791d2 (diff)
downloadfaker-c0b4e976d068294a34a38df96113c61285ef53d1.tar.xz
faker-c0b4e976d068294a34a38df96113c61285ef53d1.zip
docs: improve database jsdocs (#424)
Diffstat (limited to 'src/database.ts')
-rw-r--r--src/database.ts45
1 files changed, 15 insertions, 30 deletions
diff --git a/src/database.ts b/src/database.ts
index abfaea85..3e3b56f9 100644
--- a/src/database.ts
+++ b/src/database.ts
@@ -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
@@ -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(
@@ -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(
@@ -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(