plugin-typeorm

A plugin to allow Fluse fixtures to interact with a TypeORM connection.

Install#

yarn add -D fluse-plugin-typeorm typeorm
tip

This plugin requires typeorm to be installed as well.

Example#

import { fluse } from "fluse";
import typeormPlugin from "fluse-plugin-typeorm";
const { fixture, scenario } = fluse({
plugins: {
orm: typeormPlugin(),
},
});
const userFixture = fixture<User>({
create({ orm }) {
const user = orm.entityManager.getRepository(User).create({
username: "bob",
});
return orm.entityManager.save(user);
},
});

API Reference#

The EntityManager and Connection from typeorm will become available on the context and a runtime option as you use this plugin.

Signature#

typeormPlugin(config?: {
connection?: Connection | string;
transaction?: boolean;
synchronize?: boolean;
dropBeforeSync?: boolean;
}) => Plugin
  • connection (optional): The name of the connection, or an instance of a TypeORM connection, defaults to default,
  • transaction (optional): Run the fixture (or combined fixtures) in a single transaction, rolling back if something fails,
  • synchronize (optional): Synchronize the database before running the fixture,
  • dropBeforeSync (optional): Drop the database entirely before sychronizing,