@rattus-orm/angular-rxjs
v0.2.2
Published
ORM for your JS/TS apps: Angular RxJS bindings
Downloads
83
Maintainers
Readme
Angular + RxJS bindings for Rattus ORM
Contents
- RattusOrmModule - module for Angular.
Installation
Use your favorite package manager. For example, yarn:
yarn add @rattus-orm/core @rattus-orm/angular-rxjs
Basic usage
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())
}
}
Documentation
For detailed docs please read documentation website.
Contributing
Contributions are welcome! Please read our Contributing Guide for details on our code of conduct, and the process for submitting pull requests.