Angular + RxJS bindings for Rattus ORM
- RattusOrmModule - module for Angular.
Use your favorite package manager. For example, yarn:
yarn add @rattus-orm/core @rattus-orm/angular-rxjs
import { ApplicationConfig, importProvidersFrom } from '@angular/core';
import { RattusOrmModule } from "@rattus-orm/angular-rxjs";
export const appConfig: ApplicationConfig = {
providers: [
// ...
importProvidersFrom(RattusOrmModule.forRoot())
],
};
export class User extends Model {
public static entity = 'user'
@Uid()
public id: string
@Str()
public email: string
}
@Component({
selector: 'app-root',
standalone: true,
imports: [AsyncPipe],
template: '<p>{{ (user | async)?.email }}</p>',
})
export class AppComponent {
public user: BehaviorSubject<Item<User>>
constructor(
protected readonly contextService: RattusContextService,
) {
const userRepo = contextService.getRepository(User)
this.user = userRepo.observe((repo) => repo.query().where('id', '1').first())
}
}
For detailed docs please read documentation website.
Contributions are welcome! Please read our Contributing Guide for details on our code of conduct, and the process for submitting pull requests.