# @ksfks/oracle-client

> 远程调用oreacleServer ksf服务

Latest version **1.0.1** (published 2023-03-16) · ISC license · 0 weekly downloads

## Install

```sh
npm install @ksfks/oracle-client
pnpm add @ksfks/oracle-client
yarn add @ksfks/oracle-client
bun add @ksfks/oracle-client
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2023-03-16 |
| First published | 2023-03-10 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 37.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | juli.xiong, zhaozhi, jiaminzou, yinuu |

## Links

- npm: https://www.npmjs.com/package/@ksfks/oracle-client
- npm.io page: https://npm.io/package/@ksfks/oracle-client

## Dependencies (1)

- [@ksfcore/rpc](https://npm.io/package/@ksfcore/rpc.md) latest

## Recent versions

- 1.0.1 (latest) — 2023-03-16
- 1.0.0 — 2023-03-10

## README

## 作用

远程调用oreacleServer ksf服务

## 用法示例
```javascript
    var oracleClientHelper = require("@ksfks/oracle-client")("testbus","upapp")

    /**
     * oracle查询
     * @param string   查询SQL语句
     * @param json     JSON格式的绑定数据（如果SQL语句不带绑定标志位，可以不传）
     * @param number   最大查询记录数（如果不传，将读取默认值）
     */

    //如果不带绑定参数，可以只传SQL语句和最大查询数
    oracleClientHelper.query('select * from (select t.*,rownum from UPAPP.NEWS_MAIN_ELE t)', 100).then(data =>{
        console.log(data);
    })

    //最简单时候可以只传一条SQL语句作为参数，此时最大查询数将读取默认值
    oracleClientHelper.query('select * from (select t.*,rownum from UPAPP.NEWS_MAIN_ELE t)').then(data =>{
        console.log(data);
    })

    //绑定数据查询，推荐传入JSON对象，标识符和键值保持一致
    oracleClientHelper.query('select * from UPAPP.STK_BASIC_INFO where STK_UNI_CODE = :skt_uni_code', {skt_uni_code: '2010003382'}, 100).then(data =>{
        console.log(data);
    })

    //如果偷懒的话也可以传数组，不过这样将会按顺序对号入座
    oracleClientHelper.query('select * from UPAPP.STK_BASIC_INFO where STK_UNI_CODE = :skt_uni_code', ['2010003382'], 100).then(data =>{
        console.log(data);
    })

    //兼容了老接口：queryBindParams
    oracleClientHelper.queryBindParams('select * from UPAPP.STK_BASIC_INFO where STK_UNI_CODE = :skt_uni_code', ['2010003382'], 100).then(data =>{
        console.log(data);
    })

    /**
     * oracle查询，加入缓存机制
     *
     * @param json sqlString  查询SQL语句
     *             bindParams JSON格式的绑定数据（如果SQL语句不带绑定标志位，可以不传）
     *             maxRowNum  最大查询记录数，如果不传，读取服务默认配置
     *             expireTime 缓存过期时间，单位秒，如果不传，读取服务默认配置
     *             isForce    是否强刷，如果不传，读取服务默认配置
     */
     
    //最简单的用法，会优先去缓存拿数据，如果没有直接查数据库
    oracleClientHelper.queryCache({
        sqlString:  'select * from UPAPP.STK_BASIC_INFO where STK_UNI_CODE = 2010003382',
    }).then(data => {console.log(data);}).catch(err => {console.log(err);});
     
    //可以限制最大查询数量，如果不传，读取服务默认配置
    oracleClientHelper.queryCache({
        sqlString:  'select * from UPAPP.STK_BASIC_INFO where STK_UNI_CODE = 2010003382',
        maxRowNum:  100
    }).then(data => {console.log(data);}).catch(err => {console.log(err);});
     
    //可以绑定参数
    oracleClientHelper.queryCache({
        sqlString:  'select * from UPAPP.STK_BASIC_INFO where STK_UNI_CODE = :skt_uni_code',
        bindParams: {skt_uni_code: '2010003382'},
        maxRowNum:  100
    }).then(data => {console.log(data);}).catch(err => {console.log(err);});
     
    //同时我们也可以手动设置缓存过期时间，单位秒，如果没设置，读取服务默认配置
    oracleClientHelper.queryCache({
        sqlString:  'select * from UPAPP.STK_BASIC_INFO where STK_UNI_CODE = :skt_uni_code',
        bindParams: {skt_uni_code: '2010003382'},
        maxRowNum:  100,
        expireTime: 60
    }).then(data => {console.log(data);}).catch(err => {console.log(err);});
     
    //服务器配置默认取缓存，如果不想拿缓存的数据，也可以强刷
    oracleClientHelper.queryCache({
        sqlString:  'select * from UPAPP.STK_BASIC_INFO where STK_UNI_CODE = :skt_uni_code',
        bindParams: {skt_uni_code: '2010003382'},
        maxRowNum:  100,
        expireTime: 60,
        isForce:    true
    }).then(data => {console.log(data);}).catch(err => {console.log(err);});

    //最后我们也可以人为指定缓存key
    oracleClientHelper.queryCache({
        sqlString:  'select * from UPAPP.STK_BASIC_INFO where STK_UNI_CODE = :skt_uni_code',
        bindParams: {skt_uni_code: '2010003382'},
        maxRowNum:  100,
        expireTime: 60,
        isForce:    true,
        cacheKey:   'oracle_srv_test'
    }).then(data => {console.log(data);}).catch(err => {console.log(err);});
```

---
_Source: https://npm.io/package/@ksfks/oracle-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
