@micro-fleet/persistence
v2.4.0-rc1
Published
Provides base repository class and database connector that helps connect to database and map db tables to JS objects (ORM).
Readme
Micro Fleet - Backend Persistence library
Belongs to Micro Fleet framework, provides base repository class with pre-implemented CRUD operations.
INSTALLATION
- Stable version:
npm i @micro-fleet/persistence - Edge (development) version:
npm i git://github.com/gennovative/micro-fleet-persistence.git
DEVELOPMENT
TRANSPILE CODE
- Install packages in
peerDependenciessection with commandnpm i --no-save {package name}@{version}. Or if you want to use directly neighbor packages, excutenpm run linkPackages. npm run buildto transpile TypeScript then run unit tests (if any) (equiv.npm run compile+npm run test(if any)).npm run compile: To transpile TypeScript into JavaScript.npm run watch: To transpile without running unit tests, then watch for changes in *.ts files and re-transpile on save.npm run test: To run unit tests.- After tests finish, open file
/coverage/index.htmlwith a web browser to see the code coverage report which is mapped to TypeScript code.
- After tests finish, open file
CREATE UNIT TEST DATABASE
One of the quickest ways to set up the test environment is to use Docker:
docker run -d --name postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 postgres:9.6-alpineCreate a database name
unittest-persistence. If you want to change the name as well as database credentials, edit file/src/test/database-details.tsthen executenpm run compile.Install knex globally:
npm i -g knexJump to database migration folder:
cd databaseExecute:
knex migrate:latestNote:
- Existing tables are dropped.
- If you want to re-run migration script, truncate all rows in
knex_migrationstable in database.
RELEASE
npm run release: To transpile and createapp.d.tsdefinition file.- Note: Please commit transpiled code in folder
distand definition fileapp.d.tsrelevant to the TypeScript version.
