Skip to content

The nestjs project uses the repository pattern for both mysql and mongodb. Help every one understand deeplier about this pattern.

Notifications You must be signed in to change notification settings

AdrienNguyen/repository-pattern-for-sql-and-mongodb

Repository files navigation

REPOSITORY PATTERN FOR SQL AND MONGODB

SQL (Typeorm) and MongoDB (Mongoose)

Inject repository in class service

@Injectable()
export class UserService {
  constructor(
    @Inject('USERSQL_REPOSITORY')
    private readonly userRepository: UserRepository,
  ) {}
  async findUserByEmail(email: string): Promise<any> {
    const user = await this.userRepository.findUserByEmail(email);
    return user;
  }
}

USERSQL_REPOSITORY = "USERSQL" + _ + "REPOSITORY" = ENTITYNAME (to uppercase) + _ + "REPOSITORY"

About

The nestjs project uses the repository pattern for both mysql and mongodb. Help every one understand deeplier about this pattern.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •