nf-tax-repository
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

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);

Readme

Keywords

Package Sidebar

Install

npm i nf-tax-repository

Weekly Downloads

1

Version

1.0.0

License

ISC

Unpacked Size

5.52 kB

Total Files

11

Last publish

Collaborators

  • negar_fathi