How to use typeorm-seeding - 10 common examples

To help you get started, we’ve selected a few typeorm-seeding examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github w3tecch / express-typescript-boilerplate / test / e2e / utils / server.ts View on Github external
export const prepareServer = async (options?: { migrate: boolean }) => {
    const settings = await bootstrapApp();
    if (options && options.migrate) {
        await migrateDatabase(settings.connection);
    }
    setConnection(settings.connection);
    return settings;
};
github freeCodeCamp / chapter / server / factories / chapter.factory.ts View on Github external
import Faker from 'faker';
import { define } from 'typeorm-seeding';

import { Chapter } from '../models/Chapter';
import { User } from '../models/User';
import { Location } from '../models/Location';

define(Chapter, (
  faker: typeof Faker,
  params: { creator: User; location: Location },
) => {
  const { creator, location } = params;

  const name = faker.company.companyName();
  const description = faker.lorem.words();
  const category = faker.lorem.word();
  const details = {
    email: faker.internet.email(),
  };

  const chapter = new Chapter({
    name,
    description,
    category,
github freeCodeCamp / chapter / server / factories / user.factory.ts View on Github external
import Faker from 'faker';
import { define } from 'typeorm-seeding';
import { User } from '../models/User';

define(User, (faker: typeof Faker) => {
  const user = new User({
    email: faker.internet.email(),
    first_name: faker.name.firstName(),
    last_name: faker.name.lastName(),
  });

  return user;
});
github w3tecch / express-typescript-boilerplate / src / database / seeds / CreatePets.ts View on Github external
public async seed(factory: Factory, connection: Connection): Promise {
        const em = connection.createEntityManager();
        await times(10, async (n) => {
            const pet = await factory(Pet)().seed();
            const user = await factory(User)().make();
            user.pets = [pet];
            return await em.save(user);
        });
    }

typeorm-seeding

🌱 A delightful way to seed test data into your database.

MIT
Latest version published 5 years ago

Package Health Score

47 / 100
Full package analysis

Similar packages