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

rel-query-engine

v1.0.0-beta.2

Published

Allows managing multiple databases simultaneously for Relteco-Relnode.

Downloads

1

Readme

rel-query-engine

Allows managing multiple databases simultaneously for Relteco-Relnode.

For now, it only supports PostgreSQL

npm i rel-query-engine

Quick Start


// First, create a `connectionList` array and add objects containing connection information, a `nickname` that defines your database, and other relevant details
const connectionList =[
   {name:"LiveDB",engine:Engines.PGSQL,domain:"localhost",port:5432,dbuser:"postgres",dbname:"postgres",dbpassword:"password"},
   {name:"DevDB",engine:Engines.PGSQL,domain:"localhost",port:5432,dbuser:"postgres",dbname:"postgres",dbpassword:"password"},
   {name:"DevMysqlDB",engine:Engines.MYSQL,domain:"localhost",port:6632,dbuser:"root",dbname:"mysql",dbpassword:"password"},
   //... more ...
]
// Now, you can create your `relqueryengine` with the `connectionList` array.
const RQE =new RelQueryEngine(connectionList)

// Now, let's retrieve the `connections` from memory.
  const DBS = RQE.Connections

// Now, you can call the desired database connection using the alias you provided earlier.
  let db =  await DBS.liveDB.LISTDB("postgres")
//                     - ^ -

NOTE :RelQueryEngine dynamically creates the Connections object. This can lead to reminders not working properly in some IDEs.For example, the LISTDB function may not be recognized by the IDE in the above example. To provide an alternative solution to this issue,you can use RelQueryEngine as follows:

// Instead of creating a connectionList array, create a connectionList object.
// Request RelQueryEngine (RQE) to directly return CONNECT with a key as the alias you will provide for your database and object values.
// You can even create this object in a different file, export it, and make it accessible throughout your project.
  const myconnections ={
   LiveDB:RQE.CONNECT({engine:Engines.PGSQL,domain:"localhost",port:5432,dbuser:"postgres",dbname:"postgres",dbpassword:"password"}),
   DevDB:RQE.CONNECT({engine:Engines.PGSQL,domain:"localhost",port:5432,dbuser:"postgres",dbname:"postgres",dbpassword:"password"})
   DevMysqlDB:RQE.CONNECT({engine:Engines.MYSQL,domain:"localhost",port:6632,dbuser:"root",dbname:"mysql",dbpassword:"password"}),

 }

 // Now, you can establish connections based on the aliases from the `myconnections` object.
 // You will notice that your IDE can more easily recognize the LISTDB function.
  let db =  await myconnections.liveDB.LISTDB("postgres")
//                               - ^ -

ENGINE TYPES

Engines

Database engine types

! Currently only postgresql is supported


Options

| OPTION | TYPE | DEFAULT | DESCRIPTION | :- | :- | :- | :- | PGSQL | enum | PGSQL | Postgresql engine | MYSQL | enum | MYSQL | MYSQL engine | MSSQL | enum | MSSQL | Microsoft Sql engine


  Engines.PGSQL

RELQUERYENGINE

Allows managing multiple databases together for Relteco Relnode.


Options

| OPTION | TYPE | DEFAULT | DESCRIPTION | :- | :- | :- | :- | ConnectionList | array[T_connectionList] | [] | An array of objects of type T_connection objects containing database formation


Examples:

const {RelQueryEngine,Engines} = require("rel-query-engine")

const RQE =new RelQueryEngine(connectionList)

OR


import {RelQueryEngine,Engines} = from "rel-query-engine"

const RQE =new RelQueryEngine(connectionList)

Note: The localhost value assumes that Databases is installed on your system.

ConnectionList

List of database connections to manage

It is an array consisting of objects of type T_connectionList.


  • Type: array[T_connectionList]

  • Default: []


T_connectionList Object Options

| OPTION | TYPE | DEFAULT | DESCRIPTION | :- | :- | :- | :- | name | string | "" | Database nickname | engine | enum "Engines" | "" | Database type | domain | string | localhost | Database address | port | integer | 5432 | Database port | dbuser | string | "" | Database user name | dbname | string | "" | Database name | dbpassword | string | "" | Database password


Example


const connectionlist=[
{name:"MyPgDb",engine:Engines.PGSQL,domain:"localhost",port:5432,dbuser:"postgres",dbname:"postgres",dbpassword:"password"}
]

Connections

returns database connections in memory

Return Connections


  • Type: array[T_Connections]

  • Default: []

private CREATECONNECTIONS()

creates dynamic database connection object to connection list

and associates this object with Connections.


CONNECT()

Creates database connection based on Engine type

Return connection


Options

| OPTION | TYPE | DEFAULT | DESCRIPTION | :- | :- | :- | :- | infos | object{T_Connect} | {} | database connection infos of type T_Connect


Example


 const infos ={
 engine:Engines.PGSQL,
 domain:"localhost",
 port:5432,
 dbuser:"postgres",
 dbname:"postgres",
 dbpassword:"password"
 };

 RQE.CONNECT(infos);

T_Connect infos

database connection infos of type T_Connect


T_Connect Options

| OPTION | TYPE | DEFAULT | DESCRIPTION | :- | :- | :- | :- | engine | enum "Engines" | "" | Database type | domain | string | "localhost" | Database address | port | integer | 5432 | Database port | dbuser | string | "" | Database user name | dbname | string | "" | Database name | dbpassword | string | "" | Database password