npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@acastellon/postgresql

v1.0.11

Published

Postgresql database connector focus on simplify the access to Document Storages as JSON fields

Downloads

35

Readme

module-postgresql

Postgresql database connector focus on simplify the access to Document Storages as JSON fields

configuration

saved for example as 'config.postgresql.js'

module.exports = {

     ,CERTIFICATION_PATH : '/opt/<project>/Certificate'

     ,RDS_CLOUD_CONNECTION : {
         , ACCESS_KEY_ID : <YOUR-ACCESS-KEY>
         , SECRET_ACCESS_KEY : <YOUR-SECRET-ACCESS-KEY>
         , REGION : 'eu-west-1',
     }

    , POSTGRE_URL: '127.0.0.1' | '....eu-west-1.rds.amazonaws.com'
     , POSTGRE_PORT : 5432
    , POSTGRE_USER: 'root'
    , POSTGRE_PASSWORD: 'root' // Only needed if it's not RDS based
    , POSTGRE_DATABASE: 'test'

    , TRACES : true
}

usage:

const config = require('./config.postgresql.js');
const db = require('@acastellon/module-postgresql')(config);

methods

Returns all values from a Table searching by an internal document values.
findByDocKeys(tableName, where [, docName, conditions ])

    * @param tableName - Name of the table in Postgre to look inside
    * @param where - JSON object that contains the parameters to be found on the JSON Document
    * @param docName - name of the column on table that contains the JSON data, by default: 'document'
    * @param conditions - conditions for all where values on the select , by default: ' || ', use _AND or _OR constants from db instance
    * @return an object or List of results as JSON objects
Return all values (including other columns) from a Table, looking for a matching on internal values of the document (where param)
findAllFieldsByDocKeys(tableName, where [, docName, conditions ])

    * @param tableName - Name of the table in Postgre to look inside
    * @param where - JSON object that contains the parameters to be found on the JSON Document
    * @param docName - name of the column on table that contains the JSON data, by default: 'document'
    * @param conditions - conditions for all where values on the select , by default: ' || ', use _AND or _OR constants from db instance
    * @return an object or List of results as JSON objects with all collateral FIELDS (if exists) from the same table (not only the JSON document)
Returns All data from a table based on column values
findByColumns(tableName, where [, conditions ])
    * @param tableName - Name of the table in Postgre to look inside
    * @param where - JSON object that contains the parameters to be found on the JSON Document
    * @param conditions - conditions for all where values on the select , by default: ' || ' , use _AND or _OR constants from db instance
    * @return an object or List of results as JSON objects
Insert or Update values from a JSON-document based on document matching.
It means, all documents that has the same conditions on the table referenced will be changed for the new JSON document value.
saveDocument(document, tableName, where[, docName])
    * @param document - document to be saved 
    * @param tableName - Name of the table 
    * @param where - JSON object that contains the parameters to be found on the JSON Document
    * @param docName - name of the column on table that contains the JSON data, by default: 'document'
    * @return - true if te operation was sucessfully done
Save column values inside a declared table. It can be used to update only some fields of the table.
save(values, tableName [, where])
    * @param values - to update or to be saved as a pair key-values on an Object
    * @param tableName - Name of the table
    * @param where - JSON object that contains the parameters to use in the filter search, by default = {}
    * @return - true if te operation was sucessfully done
Delete value on table

Use it carefully, if you include into the where clause just a portion of the data, it will delete ALL documents that has the same pattern Preferable to use an approach of an additional column as UUID to proceed to delete, instead to use matches of the properties on the document (if you're not sure that one of the property is unique).

remove(tableName, where, docName)
    * @param tableName - Name of the table
    * @param where - JSON object that contains the parameters to use in the filter
    * @param docName - name of the column on table that contains the JSON data, if it's NULL means to search by column values on table not inside the document.
    * @return - true if te operation was sucessfully done
Execute an SQL sentence directly

Use it carefully, only in case that a need of a complex SQL sentence.

execute(sql, params)
    * @param sql - SQL sentence to be executed
    * @param params - parameters to use in the SQL sentence ($1, $2, etc) as an Array of values or Objects.
    * @return an object or List of results as JSON objects