nf-tax-repository
v1.0.0
Published
generic repository pattern
Downloads
3
Readme
Repository Pattern for building CRUD service to Front-End
Service method
The service allows you to persists data to Map or localStorgate ...
Service Methods.
- In
get
for retriving one item - In
add
for adding one item - In
update
for updating one item - In
filter
for qurey - In
remove
for removing one item
Full example:
import { RepositoryProvider } from "./data/repository";
import { PersonRepositoryFactory } from "./services/person.repository";
import Person from "./models/person";
// import PersonRepository from "./repositories/person.repository";
// let respository = new PersonRepository();
let respository = PersonRepositoryFactory.create(RepositoryProvider.Map);
try {
respository.add(new Person(1, "reza bardal1"));
respository.add(new Person(2, "reza bardal2"));
} catch (error) {}
console.log(respository.filter((item) => item.id > 1));
// localStorage.setItem("1", JSON.stringify(new Person(1, "reza bardal1")));
// let p : Person = JSON.parse(localStorage.getItem("1")) as Person;
// console.log(p);