本文整理汇总了TypeScript中faker.lorem.sentences方法的典型用法代码示例。如果您正苦于以下问题:TypeScript lorem.sentences方法的具体用法?TypeScript lorem.sentences怎么用?TypeScript lorem.sentences使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类faker.lorem
的用法示例。
在下文中一共展示了lorem.sentences方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: return
export const makeBook = (authorId: number): BookModel => {
return (new BookModel())
.setTitle(lorem.word())
.setDescription(lorem.sentences(2))
.setPrice(random.number(120) + (random.number(99) / 100))
.setPublishedAt(date.past())
.setAuthorId(authorId);
};
示例2: switch
function getSanitizedValue<D>(
defaultValue: D,
sanitizeConfig?: SanitizeConfig
) {
if (!sanitizeConfig) return defaultValue;
switch (sanitizeConfig) {
case 'name':
return faker.name.findName();
case 'email':
return faker.internet.email();
case 'lorem':
return faker.lorem.sentences();
default:
return faker.lorem.text();
}
}
示例3: initDb
/** Create the database. */
async function initDb() {
// Creates the file.
try {
await sequelize.authenticate();
console.log('Connection to the database successful.');
} catch (error) {
console.log(`Error while trying to connect to the database: ${error}`);
}
// Syncs the model
try {
await sequelize.sync({force: true});
console.log('Database sync sucessful');
} catch (error) {
console.log(`Error while trying to sync the model with the database : ${error}`);
}
if (process.env.DB_ENV !== 'prod') {
// Populate the database with fake data
try {
let data: IArticle[] = [];
for (let i = 0; i < 10; i++) {
data.push({
title: faker.commerce.department(),
description: faker.lorem.sentence(),
content: faker.lorem.sentences(),
published: faker.random.boolean(),
publishedAt: new Date().toISOString()
});
}
await Article.bulkCreate(data);
console.log('10 articles successfully inserted.');
} catch (error) {
console.log(`Error while trying to insert an article in the database : ${error}`);
}
}
}