restlesspgorm
v0.9.25
Published
RestlessPgOrm is an ORM layer for PostgreSQL databases.
Downloads
4
Readme
RestlessPgOrm
RestlessPgOrm is a simple NodeJS ORM system for accessing PostgreSQL databases. It is slightly opinionated, with the following philosophies:
- Databases should be self-contained: You should be able to get a database login and get to work.
- Configuration should be minimal: You shouldn't require a schema configuration written in some DSL to use your database. The proofe should be in the pudding.
- ORMs should stay out of the way: Database ORMs often try to impose a new way of accessing data. Not RestlessPgOrm. You can always drop down to SQL if you want.
Getting started
You can install RestlessPgOrm via npm:
npm install --save restlesspgorm
To get it working in your environment, it requires a few environment variables to be set:
- RESTPGORM_DB_HOST: The database hostname
- RESTPGORM_DB_PORT: The database port (optional, defaults to 5432),
- RESTPGORM_DB_NAME: The database schema name
- RESTPGORM_DB_USERNAME: The database user name
- RESTPGORM_DB_PASSWORD: The database password
- RESTPGORM_CACHE_FILE: The path to your database cache file (the ORM creates this file for you)
Since the library is built on pg-promise
and uses a connection pool, you can also specify some other environment variables if you'd like:
- RESTPGORM_DB_POOL_MAX: The number of connections in the pool (defaults to 5),
- RESTPGORM_DB_POOL_IDLE_TIMEOUT: The period after which connections expire in milliseconds (defaults to 30000ms),
After you have installed the library and set the appropriate environment variables, you can cache your schema with the following command:
npx cacheSchema
This will create the file that the library will use to access your database.