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

data-domain-driver

v0.2.1

Published

DDD: DataDomainDriver, Alternative **Legacy** Stored Procedures

Downloads

4

Readme

data-domain-driver

DDD: Data Domain Driver, Alternative **Legacy** Stored Procedures

Installation

$ # Configuration file and DDD definition file must be placed
$ npm install data-domain-driver

Quick Play

$ git clone https://github.com/nmrmsys/data-domain-driver.git
$ cd data-domain-driver
$ npm install
$ npm test

Basic Usage

// test.js
const DDD = new (require('data-domain-driver').DDD)();

returns = await DDD.callProcedure('proc01', params);
returns = await DDD.domain('another').callProcedure('procA', params);

DDD.end();
// proc01.js
const Procedure = require('data-domain-driver').Procedure;

Class proc01 extends Procedure {

  async process(ddd, params, returns){
    
    // sql-behind named SQL statement or raw SQL string can be specified
    rs1 = await ddd.query('query1', {FLD1:'1', FLD2:'A'});

    while(!rs1.EOF){
      
      console.log(rs1.FLD1 + ', ' + rs1.FLD2 + ', ' + rs1.FLD3);
      
      rs1.next();
    }

    await ddd.execute('stmt1', {FLD1:'1', FLD2:'A', FLD3:'zzz'});

    ret1 = await ddd.callFunction('func01', params);

    await ddd.database('mydb2').execute('stmt2', params);

    rs2 = await ddd.database('webapi3').query('query2', params);

    returns.result1 = rs1;
    returns.result2 = rs2;
    
    return 0; // returns.returnCode
  }

}
-- proc01.sql
/**
 * @name query1
 * @desc Get data from TBL1
 * @param :FLD1 - Search condition of FLD1
 * @param :FLD2 - Search condition of FLD2
 * @return TBL1 result set
 */
SELECT
  FLD1
 ,FLD2
 ,FLD3
FROM TBL1
WHERE FLD1 = :FLD1
  AND FLD2 = :FLD2
// func01.js
const Function = require('data-domain-driver').Function;

Class func01 extends Function {
  
  async process(ddd, params, returns){

    returns.resultA = params;

    return 0; // returns.returnCode
  }
  
}

One Table Query Builder

// procA.js
const Procedure = require('data-domain-driver').Procedure;

Class procA extends Procedure {

  async process(ddd, params, returns){
    
    // ddd.select(tblId, selClas, wheClas, ordClas, grpClas, havClas)
    rs = await ddd.select('TBL1', ['FLD1', 'FLD2'], {FLD1: '2'}, 'FLD1');

    // ddd.insert(tblId, insClas)
    await ddd.insert('TBL1', {FLD1: '4', FLD2: 'D', FLD3: 'jkl'});

    // ddd.update(tblId, updClas, wheClas)
    await ddd.update('TBL1', {FLD1: '1x', FLD2: 'Ax'}, {FLD1: '1', FLD2: 'A'});

    // ddd.delete(tblId, wheClas)
    await ddd.delete('TBL1', {FLD1: '3', FLD2: 'C'});

    // ddd.get(tblId, selClas, wheClas, ordClas, grpClas, havClas)
    v = await ddd.get('TBL1', 'FLD2', {FLD1: '2'});

    // ddd.set(tblId, setClas, wheClas)
    await ddd.set('TBL1', {FLD2: 'D', FLD3: 'jkl'}, {FLD1: '4'});

    return 0; // returns.returnCode
  }

}

Dataset Anything Mapping

// test.js
const DDD = new (require('data-domain-driver').DDD)();
returns = await DDD.callProcedure('proc01', params);
DDD.end();

// DataSet.toJSON(
//   mainDataDef     -  'jsonName=dataName[keyName, ...]'
//   ,relationDefs   -  {'relationName': 'dataName[keyName, ...]'}
// )
ordJson = returns.toJSON('orders=ORDER[ORDER_ID]', {'details': 'DETAIL[ORDER_ID]'});

// DataSet.toObject(
//   mainDataDef     -  'className=dataName[keyName, ...]'
//   ,relationDefs   -  {'relationName': 'className=dataName[keyName, ...]'}
// )
ordObj = returns.toObject('Order=ORDER[ORDER_ID]', {'details': 'Detail=DETAIL[ORDER_ID]'});
// Order.js
const Model = require('data-domain-driver').Model;

module.exports = class Order extends Model {

    // constructor(data){
    //     super(data);
    // }
    
    get data(){
        return super.data;
    }
    
    set data(data){
        super.data = data;
        // Write custom data setting if needed
    }

    // Write domain logic here

}

Licence

MIT

Author

nmrmsys