Generate system, database, and technical data for development and testing scenarios. These modules provide essential utilities for creating realistic technical environments, database schemas, and communication data.
Generate database-related data including column names, data types, and database system information.
/**
* Generate a database column name
* @returns Random database column name
*/
column(): string;
/**
* Generate a database data type
* @returns Random database data type (VARCHAR, INT, etc.)
*/
type(): string;
/**
* Generate a database collation
* @returns Random database collation setting
*/
collation(): string;
/**
* Generate a database engine name
* @returns Random database engine (InnoDB, MyISAM, etc.)
*/
engine(): string;
/**
* Generate a MongoDB ObjectId
* @returns Valid MongoDB ObjectId string
*/
mongodbObjectId(): string;Usage Examples:
import { faker } from "@faker-js/faker";
// Generate database schema elements
const columnName = faker.database.column();
// Example: 'user_id'
const dataType = faker.database.type();
// Example: 'VARCHAR'
const collation = faker.database.collation();
// Example: 'utf8_unicode_ci'
const engine = faker.database.engine();
// Example: 'InnoDB'
// Generate MongoDB ObjectId
const objectId = faker.database.mongodbObjectId();
// Example: '507f1f77bcf86cd799439011'
// Create database table schema
const tableSchema = {
tableName: faker.lorem.word(),
columns: Array.from({ length: faker.number.int({ min: 3, max: 8 }) }, () => ({
name: faker.database.column(),
type: faker.database.type(),
nullable: faker.datatype.boolean(),
defaultValue: faker.datatype.boolean() ? faker.string.alphanumeric(10) : null
})),
engine: faker.database.engine(),
collation: faker.database.collation()
};
// Generate database migration data
const migrationData = Array.from({ length: 5 }, () => ({
id: faker.database.mongodbObjectId(),
table: faker.lorem.word(),
operation: faker.helpers.arrayElement(['CREATE', 'ALTER', 'DROP', 'INSERT']),
column: faker.database.column(),
dataType: faker.database.type(),
timestamp: faker.date.recent()
}));Generate phone numbers in various formats and styles for different regions and use cases.
/**
* Generate a phone number
* @param options - Phone number options
* @returns Formatted phone number string
*/
number(options?: {
/** Style of the phone number */
style?: 'human' | 'national' | 'international';
}): string;Usage Examples:
import { faker } from "@faker-js/faker";
// Generate different phone number styles
const humanPhone = faker.phone.number();
// Example: '961-770-7727'
const humanReadable = faker.phone.number({ style: 'human' });
// Example: '555.770.7727 x1234'
const nationalPhone = faker.phone.number({ style: 'national' });
// Example: '(961) 770-7727'
const internationalPhone = faker.phone.number({ style: 'international' });
// Example: '+15551234567'
// Create contact information
const contactInfo = {
name: faker.person.fullName(),
email: faker.internet.email(),
phone: {
mobile: faker.phone.number({ style: 'human' }),
office: faker.phone.number({ style: 'national' }),
international: faker.phone.number({ style: 'international' })
},
address: faker.location.streetAddress({ useFullAddress: true })
};
// Generate phone directory
const phoneDirectory = Array.from({ length: 20 }, () => ({
id: faker.string.uuid(),
name: faker.person.fullName(),
phone: faker.phone.number({ style: 'national' }),
mobile: faker.phone.number({ style: 'human' }),
department: faker.commerce.department(),
extension: faker.string.numeric(4)
}));Generate file system related data including file names, extensions, paths, and MIME types.
/**
* Generate a common file extension
* @returns Common file extension (pdf, jpg, etc.)
*/
commonFileExt(): string;
/**
* Generate a common file name
* @param ext - Optional specific extension
* @returns File name with extension
*/
commonFileName(ext?: string): string;
/**
* Generate a common file type category
* @returns File type category (audio, image, video, etc.)
*/
commonFileType(): string;
/**
* Generate a directory path
* @returns Unix-style directory path
*/
directoryPath(): string;
/**
* Generate a file extension
* @param mimeType - Optional MIME type filter
* @returns File extension
*/
fileExt(mimeType?: string): string;
/**
* Generate a file name
* @param options - File name options
* @returns File name with extension
*/
fileName(options?: {
/** Number of extensions to include */
extensionCount?: number;
}): string;
/**
* Generate a complete file path
* @returns Complete file path with directory and filename
*/
filePath(): string;
/**
* Generate a file type/MIME type
* @returns MIME type string
*/
fileType(): string;
/**
* Generate a MIME type
* @returns MIME type string
*/
mimeType(): string;
/**
* Generate a semantic version string
* @returns Semantic version (1.2.3 format)
*/
semver(): string;Usage Examples:
import { faker } from "@faker-js/faker";
// Generate file system elements
const fileExtension = faker.system.commonFileExt();
// Example: 'pdf'
const fileName = faker.system.commonFileName();
// Example: 'document.pdf'
const customFileName = faker.system.commonFileName('jpg');
// Example: 'image.jpg'
const fileType = faker.system.commonFileType();
// Example: 'image'
const directoryPath = faker.system.directoryPath();
// Example: '/home/user/documents'
const fullFilePath = faker.system.filePath();
// Example: '/var/log/application.log'
const mimeType = faker.system.mimeType();
// Example: 'image/jpeg'
const version = faker.system.semver();
// Example: '2.1.4'
// Create file system structure
const fileSystemStructure = {
root: faker.system.directoryPath(),
files: Array.from({ length: 10 }, () => ({
name: faker.system.fileName(),
path: faker.system.filePath(),
type: faker.system.fileType(),
size: faker.number.int({ min: 1024, max: 10485760 }), // 1KB to 10MB
created: faker.date.past(),
modified: faker.date.recent()
})),
directories: Array.from({ length: 5 }, () => ({
name: faker.lorem.word(),
path: faker.system.directoryPath(),
created: faker.date.past()
}))
};
// Generate software project data
const softwareProject = {
name: faker.lorem.words(2),
version: faker.system.semver(),
files: Array.from({ length: 15 }, () => ({
filename: faker.system.fileName(),
path: faker.system.filePath(),
mimeType: faker.system.mimeType(),
extension: faker.system.fileExt()
})),
dependencies: Array.from({ length: 8 }, () => ({
name: faker.lorem.word(),
version: faker.system.semver()
}))
};import { faker } from "@faker-js/faker";
// Simulate file upload API response
const fileUploadResponse = {
success: true,
data: {
fileId: faker.database.mongodbObjectId(),
originalName: faker.system.commonFileName(),
mimeType: faker.system.mimeType(),
size: faker.number.int({ min: 1024, max: 5242880 }),
path: faker.system.filePath(),
uploadedAt: faker.date.recent(),
checksum: faker.string.alphanumeric(32)
}
};
// Simulate contact management system
const contactManagementSystem = Array.from({ length: 50 }, () => ({
id: faker.database.mongodbObjectId(),
name: faker.person.fullName(),
company: faker.company.name(),
email: faker.internet.email(),
phone: faker.phone.number({ style: 'national' }),
mobile: faker.phone.number({ style: 'human' }),
address: {
street: faker.location.streetAddress(),
city: faker.location.city(),
zipCode: faker.location.zipCode(),
country: faker.location.country()
},
metadata: {
created: faker.date.past(),
modified: faker.date.recent(),
version: faker.system.semver()
}
}));import { faker } from "@faker-js/faker";
// Generate database seed data
const databaseSeed = {
users: Array.from({ length: 100 }, () => ({
_id: faker.database.mongodbObjectId(),
username: faker.internet.username(),
email: faker.internet.email(),
phone: faker.phone.number({ style: 'international' }),
profile: {
firstName: faker.person.firstName(),
lastName: faker.person.lastName(),
avatar: faker.image.avatar()
},
preferences: {
language: faker.location.countryCode(),
timezone: faker.date.timeZone(),
notifications: faker.datatype.boolean()
},
metadata: {
createdAt: faker.date.past(),
updatedAt: faker.date.recent(),
version: faker.system.semver()
}
})),
files: Array.from({ length: 200 }, () => ({
_id: faker.database.mongodbObjectId(),
filename: faker.system.fileName(),
mimeType: faker.system.mimeType(),
size: faker.number.int({ min: 1024, max: 104857600 }),
path: faker.system.filePath(),
uploadedBy: faker.database.mongodbObjectId(),
tags: Array.from({ length: faker.number.int({ min: 1, max: 5 }) }, () =>
faker.lorem.word()
),
metadata: {
uploadedAt: faker.date.past(),
lastAccessed: faker.date.recent()
}
}))
};import { faker } from "@faker-js/faker";
// Generate system configuration data
const systemConfig = {
application: {
name: faker.lorem.words(2),
version: faker.system.semver(),
environment: faker.helpers.arrayElement(['development', 'staging', 'production']),
port: faker.number.int({ min: 3000, max: 9999 })
},
database: {
host: faker.internet.ip(),
port: faker.number.int({ min: 1000, max: 65535 }),
name: faker.lorem.word(),
engine: faker.database.engine(),
collation: faker.database.collation(),
maxConnections: faker.number.int({ min: 10, max: 100 })
},
files: {
uploadPath: faker.system.directoryPath(),
maxFileSize: faker.number.int({ min: 1048576, max: 104857600 }), // 1MB to 100MB
allowedTypes: Array.from({ length: 5 }, () => faker.system.mimeType()),
tempDirectory: faker.system.directoryPath()
},
communication: {
supportPhone: faker.phone.number({ style: 'international' }),
adminPhone: faker.phone.number({ style: 'national' }),
emergencyContact: faker.phone.number({ style: 'human' })
}
};Different styles provide different use cases:
The system includes comprehensive MIME type support:
Semantic versioning follows the standard format: