Repositories are used to interact with the database
Repositories in Orionjs are specialized services that handle data access operations. They follow the repository pattern, which separates data access logic from business logic, making your code more maintainable and testable.
Like services, repositories can be injected into other components using the factory function pattern:
Copy
import {Service, Inject} from '@orion-js/services'import {UserRepository} from './UserRepository'@Service()export class UserService { @Inject(() => UserRepository) private userRepository: UserRepository async validateAndCreateUser(userData: {name: string; email: string}) { // Business logic and validation here // Use repository for data operations return this.userRepository.create(userData) }}