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

database-common-utils

v1.0.9

Published

"# node-database-common-utils"

Readme

##node-database-common-utils APLGv3开源协议 ###如何配置数据库环境

  1. 介绍 当前代码是基于oracledb做的封装,所以如果您要使用此工具类,需要安装和配置oracledb

  2. 如何安装oracledb 下载instantclient-basiclite以及instantclient-sdk http://www.oracle.com/technetwork/database/features/instant-client/index.html

    配置环境变量

    OCI_INC_DIR=D:${下载文件解压的目录}\sdk\include\
    OCI_LIB_DIR=D:${下载文件解压的目录}\sdk\lib\msvc\
    执行 npm install oracledb --save
    执行 npm install node-gyp --save
    执行 npm install database-common-utils --save

在此安装完毕 如果您在配置的时候遇到问题,可以在github里面发布问题,我将会里面解决....

session.update session.create session.save 这个方法的data支持数组和单个保存,如果传入进来是一个数组那么它将保存这一串数据,如果是单个,那么他将只保存单个数据

如果您使用的session.select方法,那么返回的结果全部是小写
注意为了方便您的使用,可以使用save来进行保存数据,如果使用save那么系统会自动判断当前表里面是否存在这个数据
如果您要使用save或update,那么您的数据结构必须有一个非业务的主键,叫做ID
如果您的保存数据中有数据库列的数据,那么会自动保存,如果没有,那么就丢弃当前列的数据

如何使用工具类

//创建TxSessionFactory对象
var TxSessionFactory = require('database-common-utils');

1.如何创建对象保存数据

var txsession = new TxSessionFactory("zhangj","zhangj","localhost:1521/orcl");
txsession.getTxSession().then(function(session){
  session.create({
    tablename:"TEST",
    datas:{
      id:"99",
      COLUMN1:"COLUMN1",
      COLUMN2:"COLUMN2",
      COLUMN3:"COLUMN3",
      COLUMN4:"COLUMN4",
      COLUMN5:"COLUMN5",
    }
  }).then(function(n){
    console.log(n);
    session.commit();
    session.close();
  });
});

2.如何更新数据库数据

var txsession = new TxSessionFactory("zhangj","zhangj","localhost:1521/orcl");
txsession.getTxSession().then(function(session){
  session.update({
    tablename:"TEST",
    datas:{
      id:"99",
      COLUMN1:"COLUMN3",
      COLUMN2:"COLUMN3",
      COLUMN3:"COLUMN3",
      COLUMN4:"COLUMN3",
      COLUMN5:"COLUMN3",
    }
  }).then(function(n){
    console.log(n);
    session.commit();
    session.close();
  });
});

3.如何删除数据库数据

var txsession = new TxSessionFactory("zhangj","zhangj","localhost:1521/orcl");
txsession.getTxSession().then(function(session){
  session.delete({
    tablename:"TEST",
    datas:{
      id:"99"
    }
  }).then(function(n){
    console.log(n);
    session.commit();
    session.close();
  });
});

4.如何查询数据

var txsession = new TxSessionFactory("zhangj","zhangj","localhost:1521/orcl");
txsession.getTxSession().then(function(session){
  session.select({
    sql:"select * from TEST where id=:id",
    datas:{
      id:"99"
    }
  }).then(function(n){
    console.log(n);
    session.commit();
    session.close();
  });
});

作者声明-此版本不在进行更新,最后终结版本1.0.9