| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Simple PotgreSQL wrapper for nodejs, to simplify its development.
WIP
npm install @schirrel/pg-connection --save
Uses .env to aquire credentials.
| Prop | Required | Default | Description |
|---|---|---|---|
| PG_USER | Required | ||
| PG_URL | Required | ||
| PG_DATABASE | Required | ||
| PG_PASSWORD | Required | ||
| PG_PORT | Optional | 5432 | |
| PG_SSL | Optional | false | |
| PG_REJECT_UNHAUTHORIZED | Optional | ||
| PG_LOG | Optional | false |
Using in 3 Steps
PG_USER=postgres PG_URL=localhost PG_DATABASE=postgres PG_PASSWORD=postgres PG_SCHEMA=mercado_alencar PG_LOG=true
const Model = require('@schirrel/pg-connection/Model');
class User extends Model{
constructor(args = {}){
super("USER");
this.addColumn('email', 'EMAIL');
this.addColumn('name', 'NAME');
this.addColumn('password', 'PASSWORD');
this.addColumn('active', 'ACTIVE', true);
this.setValues(args);
}
}
module.exports = User;const Repository = require('@schirrel/pg-connection/Repository');
const User = require('../models/User');
class UserRepository extends Repository{
constructor(){
super(User);
}
}
module.exports = UserRepository;And thats it.
| Back | FazBrowse Home | New Git URL |