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 🙏

© 2025 – Pkg Stats / Ryan Hefner

sqlmoses-oracle

v1.7.1

Published

A query manager for OracleDB

Readme

SQLMoses-Oracle

Seagull Waterbender Moses

npm version

A pure function model class for Oracle DB.

Methods are passed a normal object and respond with a new object. Incoming and outgoing objects are validated and transformed by Joi schemas when supplied, and transformed by processing functions when supplied.

The Model instance itself does not keep track of fields, you are expected to pass in an object to every function.

Table methods (insert, update, delete, select) are included. You can also generate stored procs methods.

You can always bind a query, which will be cached as a prepared statement by the node-oracledb driver.

Example

'use strict';

const SQLMoses = require('sqlmoses-oracle')({
  user          : "system",
  password      : "oracle",
  connectString : "192.168.1.203/orcl12c"
});

const Test = new SQLMoses.Model({
  name: 'test',
  table: 'test',
  schema: Joi.object({
    FirstName: joi.string(),
    LastName: joi.string()
  })
});

Test.select()
.then((results) => {
  //results is an array of objects
});

Install

npm i sqlmoses

Connecting

Require the module and call the module as a function, including the connection attrs object specified in oracle connection handling.

Creating a Model

new SQLMoses.Model({
  name: 'someModel'
  keyMap: {
    'renameKey': 'toThis'
  },
  schema: Joi.object(),
  processors: {
    'processorName': {
      fieldName: (input, model) => {
        return Promise.resolve(input+'modification');
      }
    }
  }
})
  • name: names the model so that you can reference it by string in map and other places
  • schema: Joi schema object. Keep in mind, joi can do transforms (rename, casting, etc)
  • processors object of processor tags with field transformations. Called when Model.process is called.
    • The custom processor fromDB is called when models are being created from the db results.
    • The custom processor toDB is called when model instances are used as input for stored procs.

Methods

select

Arguments:

opts: {
  opts.where: {
    // column: value
  },
  opts.page: {
    offset: 0
    limit: 10
  },
  order: [{'column': 'DESC'}, {'column2': 'ASC'}]

insert

Arguments:

args: {}
output: {field: SQLMoses.oracledb.[STRING or NUMBER or DATE]}

For output argument format see: oracledb output binding

update

Arguments:

args (incoming object)
where (where AND values object)

delete

Arguments

where

mapProcedure

Creates a method that runs a Stored Procedure, returning a Promise with model instances of the resulting rows.

mapProcedure(opts)

opts: {
  name: (String) name of method and stored procedure,
  args: (node-oracledb output object) see [oracledb output binding](https://github.com/oracle/node-oracledb/blob/master/doc/api.md#outbind)
}

For output argument format see: oracledb output binding

return: Promise awaiting setup.

####Usage

ModelName[name](modelobj, args)

return: Promise with array of model validated objects or a singular result if oneResult set to true.

mapQuery

Create a method that runs a raw query, returning a Promise with model instances of the resulting rows.

mapQuery(opts)

opts: {
  name: (String) name of method,
  query: (String) query to run with called, mapping arguments with :arg
}

return: undefined

validate(obj)

Validates using the Joi schema resulting in a new (remember that Joi can transform) object from a Promise.

process(obj, tags)

Runs processing tags against .processors resulting in a new object from a Promise.

validateAndProcess(obj, tags)

Runs both validation and processors resulting in a new object from a Promise.

SQLMoses.getModel(name)

model.getModel(name)

Returns the model named 'name';