Modli - PostgreSQL Adapter
This module provides adapter for the PostgreSQL datasource for integration with Modli.
Installation
npm install modli-postgres --save
Config and Usage
When defining a property which will utilize the adapter it is required that a
tableName
be supplied:
const model adapter obey use = const postgres = model
Then add the adapter as per usual with the following config object structure:
adapter
You can then use the adapter with a model via:
// Use(MODEL, ADAPTER)const postgresTest =
Methods
The following methods exist natively on the PostgreSQL adapter:
query
Allows for passing standard PostgreSQL queries:
postgresTest
createTable
Creates (IF NOT EXISTS
) a table based on params:
postgresTest
create
Creates a new record based on object passed:
postgresTest
read
Runs a SELECT
with optional WHERE
:
postgresTest
update
Updates record(s) based on query and body:
postgresTest
delete
Deletes record(s) based on query:
postgresTest
extend
Extends the adapter to allow for custom methods:
postgresTest
Development
The PostgreSQL adapter requires the following environment variables to be set for running the tests. These should be associated with the PostgreSQL instance running locally.
MODLI_POSTGRES_HOST,
MODLI_POSTGRES_USERNAME,
MODLI_POSTGRES_PASSWORD,
MODLI_POSTGRES_DATABASE
This repository includes a base container config for running locally which is located in the /docker directory.
License
Modli-Postgres is licensed under the MIT license. Please see LICENSE.txt
for full details.
Credits
Modli-Postgres was designed and created at TechnologyAdvice.