krc-dbcontext
v1.0.6
Published
dbcontext
Downloads
6
Readme
krc-dbcontext
Define common Repository pattern for database bridge by KrakenUI team!
SUPPORT DB ENGINES
- PostgreSQL
HOW IT WORKS
install package
npm install --save krc-dbcontext
usage
import { connectPgDatabase, BaseModel } from "krc-dbcontext";
const factory = await connectPgDatabase();
const productRegister = factory.register<string, Product>(
Product,
"products"
);
const productRepository = productRegister.instance;
const p = await productRepository.insert({
id: Date.now(),
name: "Product new 1",
note: "",
});
API references
ENV
| Name | args | Description | | -------------- | ------ | ----------------------- | | PG_DB_HOST | string | DB host address | | PG_DB_NAME | string | DB name | | PG_DB_USER | string | DB login user | | PG_DB_PASSWORD | string | DB login password | | PG_DB_PORT | number | DB working port | | PG_MAX_POOL | number | Maximum connection pool |
License
krc-dbcontext is released under the MIT license.