Package Exports
- @smallprod/models
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@smallprod/models) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Models by SmallProd
Presentation
This library has been made to help for the development of application which need connections to a database.
You can find exemple in the folder src/dbs/exemples.
Supported Database engine
- Postgres
How to use it ??
Postgres
In your model folder add a file just like the one presented in the exemple, just change the informations about your database
In the root of your application call this method:
import { ConnectDb } from './models/postgremodel';
(async () => {
await ConnectDb();
})();- In your model folder add a file for handling database requests like so:
import PostgreModel from '../postgremodel';
const model = PostgreModel.GetModel();
const getUsers = async () => {
return await model.query('SELECT * FROM User');
};
const getUserById = async (id: number) => {
return await model.query('SELECT * FROM User WHERE Id = $1', [id]);
};That's it !!