Skip to content

Instantly share code, notes, and snippets.

@paulodutra
Last active August 11, 2024 16:54
Show Gist options
  • Save paulodutra/b3cd742b9b96c9168c47bf749c73a6f3 to your computer and use it in GitHub Desktop.
Save paulodutra/b3cd742b9b96c9168c47bf749c73a6f3 to your computer and use it in GitHub Desktop.
InMemory database config Typeorm Nestjs
import { registerAs } from '@nestjs/config';
import { TypeOrmModuleOptions } from '@nestjs/typeorm';
export const inMemoryDatabaseConfig = registerAs(
'database.inMemory',
(): TypeOrmModuleOptions => ({
type: 'sqlite',
database: ':memory',
entities: [
__dirname +
'/../../../infrastructure/database/entities/*.entity{.ts,.js}',
],
migrations: [
__dirname +
'/../../../infrastructure/database/migrations/*.migration{.ts,.js}',
],
synchronize: true,
logging: ['error', 'query', 'warn', 'info', 'schema', 'log'],
}),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment