当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript date.past方法代码示例

本文整理汇总了TypeScript中faker.date.past方法的典型用法代码示例。如果您正苦于以下问题:TypeScript date.past方法的具体用法?TypeScript date.past怎么用?TypeScript date.past使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在faker.date的用法示例。


在下文中一共展示了date.past方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: it

			it('#bulkSave+bulkRemove', async() => {
				
				const repo = coordinator.getRepo(Fixtures.PDBRepo1)
				
				const models = []
				for (let i = 0; i < 1000; i++) {
					const model = new Fixtures.PDBModel1()
					Object.assign(model, {
						id: uuid.v4(),
						createdAt: Faker.date.past(),
						randomText: Faker.lorem.words(10)
					})
					
					models.push(model)
				}
				
				const savedModels = await repo.bulkSave(...models)
				expect(savedModels.length).toBe(models.length)
				//const nextCount = await repo.count()
				//expect(nextCount).toBe(models.length)
				
				const ids = savedModels.map(savedModel => savedModel.id)
				models.forEach(model => expect(model.$$doc).not.toBeNull())
				
				await repo.bulkRemove(...ids)
				
				const finalCount = await repo.count()
				expect(finalCount).toBe(0)
			})
开发者ID:densebrain,项目名称:typestore,代码行数:29,代码来源:PouchDBPlugin.spec.ts

示例2: getRandomPerson

export function getRandomPerson(options: GetRandomPersonOptions) {
  const opts: GetRandomPersonOptions = options || {};

  opts.maxDateOfBirth = opts.maxDateOfBirth || new Date(Date.now() - MS_IN_YEAR);
  opts.minAge = opts.minAge || 18;
  opts.maxAge = opts.maxAge || 105;
  opts.depth = opts.depth || 0;

  // Generates a family tree...of sorts
  const result: Person = {
    name: faker.name.lastName() + faker.name.firstName(),
    employment: {
      companyName: faker.company.companyName()
    },
    regex: /a/g,
    age: faker.random.number(),
    dateOfBirth: faker.date.past(),
    enrolledToVote: faker.random.boolean(),
  };

  if (opts.depth > 0) {
    result.parents = [
      getRandomPerson({ depth: opts.depth - 1 }),
      getRandomPerson({ depth: opts.depth - 1 })
    ];
  }

  return result;
}
开发者ID:codeandcats,项目名称:fast-clone,代码行数:29,代码来源:dataHelper.ts

示例3: async

				doTest = async (modelClazz,repoClazz) => {
					try {
						let
							model = new modelClazz(),
							repo = coordinator.getRepo(repoClazz)
						
						Object.assign(model, {
							id: uuid.v4(),
							createdAt: Faker.date.past(),
							randomText: Faker.lorem.words(10)
						})
						
						model = await repo.save(model)
						
						const
							model2 = Object.assign(new modelClazz(),model, {
								randomText: Faker.lorem.words(10),
								$$doc: Object.assign({},(model as any).$$doc,{
									_rev: '1-aa86c0e405a07fb76ef3e523dd1c2ae1'
								}),
							})
						
						await repo.save(model2)
						
						return null
					} catch (anErr) {
						return anErr
						
					}
				}
开发者ID:densebrain,项目名称:typestore,代码行数:30,代码来源:PouchDBPlugin.spec.ts

示例4: 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);
};
开发者ID:w3tecch,项目名称:node-ts-boilerplate,代码行数:8,代码来源:BookFactory.ts

示例5: createArray

 const products = createArray(numberOfProducts, i => {
     return [
         i,
         faker.lorem.words()[0],
         faker.finance.amount(),
         faker.date.past(),
     ]
 })
开发者ID:jakobrun,项目名称:gandalf,代码行数:8,代码来源:generatePgData.ts

示例6:

const createMessage = (channelId) => {
  return {
    id: faker.random.uuid(),
    content: faker.lorem.sentence(),
    creationTime: faker.date.past().getTime().toString(),
    author: {
      name: faker.name.firstName() + '.' + faker.name.lastName(),
      avatar: faker.image.avatar(),
    },
    channel: { id: channelId },
  };
};
开发者ID:RocketChat,项目名称:Rocket.Chat.PWA,代码行数:12,代码来源:mocks.ts


注:本文中的faker.date.past方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。