nv-pg-jrow-ir-cols-back
v1.0.3
Published
nv-pg-jrow-ir-cols-back =======================
Downloads
1
Readme
nv-pg-jrow-ir-cols-back
install
- npm install nv-pg-jrow-ir-cols-back
usage
const {creat_cols_sql} = require("nv-pg-jrow-ir-cols-back");
example
const _parser = require("/mnt/sdb/JS/BUSINESS-LIB_/PG/nv-pg-jrow/pkgs/nv-pg-jrow-back")._parser;
const unparse_func = _parser.unparse;
const _scheme = require("/mnt/sdb/JS/BUSINESS-LIB_/PG/nv-pg-jrow/pkgs/nv-pg-jrow-scheme");
var jcfg = { //non_leaf '': [c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11]
ss:'text', //leaf c0 s
aa:[ //non_leaf aa : [c1,c2,c3,c4,c5,c6]
'float8', //leaf c1 aa.0
'text', //leaf c2 aa.1
{ //non_leaf aa.2: [c3,c4]
dina_k0:'text', //leaf c3 aa.2.dina_k0
dina_k1:'text', //leaf c4 aa.2.dina_k1
},
'int4', //leaf c5 aa.3
'json' //leaf c6 aa.4
],
dd: { //non_leaf dd : [c7,c8,c9,c10,c11]
k0:'int8', //leaf c7 dd.k0
k1:'buf', //leaf c8 dd.k1
aind: [ //non_leaf dd.aind : [c9,c10,c11]
'text', //leaf c9 dd.aind.0
'text', //leaf c10 dd.aind.1
'json' //leaf c11 dd.aind.2
]
}
}
var scheme = _scheme.creat(jcfg).scheme;
var front = {
cd: [
'JPL0', 'JPL1',
'c3', 'JPL2',
'JPL3', 'c6',
'c5', 'c9',
'c1'
],
hint: {
jpl: {
JPL0: [ 'extra', 'x' ],
JPL1: [ 'extra', 'y' ],
JPL2: [ 'c11', 'x', 1, '2', 'x' ],
JPL3: [ 'c11', 'int' ]
},
jlit: {}
}
}
var cd = front.cd;
var hint = front.hint
var [cond,reason] = creat_cols_sql(cd,hint,scheme)
console.log(cond,reason)
/*
true ((extra->'x')::jsonb) AS "JPL0",((extra->'y')::jsonb) AS "JPL1",c3,((c11->'x'->1->2->'x')::jsonb) AS "JPL2",((c11->'int')::jsonb) AS "JPL3",c6,c5,c9,c1
*/
METHODS
APIS
{
ERRD: { cd_must_be_ary: 'cd_must_be_ary' },
_ir: { nv_as: [Function: nv_as] },
_vali: {
ERRD: { ele_of_cd_must_be_str: 'ele_of_cd_must_be_str' },
check_and_handle: [Function: check_and_handle]
},
creat_cols_sql: [Function: creat_cols_sql]
}
LICENSE
- ISC