@maxbuild/middleware-cosr-data
v0.0.5
Published
cosr data
Downloads
3
Readme
MAXBUILD service cosr data middleware in bpframework.
Middleware specification
https://github.com/bpcloud/middleware
usage
import {BillService, billNextPage} from '@maxbuild/middleware-cosr-data';
@Service
class TestService {
@Autowired(BillService)
billService: BillService;
// query instance.
async testQuery():Promise<any> {
let res = await this.billService.billQueryInstance('tablename', {
ownerId: 'xxxxxx',
//instanceId: 'xxxxxxx',
productCode: 'cdn',
start_at: new Date(Date.UTC(2020, 6, 17)),
// end_at: new Date(Date.UTC(2021, 6, 18)),
// limit: 1,
});
do {
console.log(res.rowLength);
} while (billNextPage(res));
console.log('query finish');
}
// execute.
async testExecute():Promise<any> {
let sql = 'UPDATE users SET birth = ? WHERE key=?';
let params = [ new Date(1942, 10, 1), 'jimi-hendrix' ];
let res = await this.billService.execute(sql, params);
do {
console.log(res.rowLength);
} while (billNextPage(res));
console.log('query finish');
}
}
Setup.
import { Application } from 'bpframework';
import * as middleware_cosr_data from '@maxbuild/middleware-cosr-data';
Application.use(middleware_cosr_data.middleware())
Application.runKoa(...);
Config.
cosr_data:
cassandra:
contactPoints:
- localhost:30042
localDataCenter: datacenter1
keyspace: cfm
# 认证信息(非必须)
credentials:
username: string
password: string
# 超时信息(非必须)
socketOptions:
connectTimeout: number
readTimeout: number