1.0.5 • Published 1 year ago
nv-pg-jrow-ir-order-by-front v1.0.5
nv-pg-jrow-ir-cols-front
install
- npm install nv-pg-jrow-ir-cols-front
usage
const { creat_order_by_for_back} = require("nv-pg-jrow-ir-cols-front");
example
const _parser = require("/mnt/sdb/JS/BUSINESS-LIB_/PG/nv-pg-jrow/pkgs/nv-pg-jrow-front")._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 a : [c1,c2,c3,c4,c5,c6]
'float8', //leaf c1 a.0
'text', //leaf c2 a.1
{ //non_leaf a.2: [c3,c4]
dina_k0:'text', //leaf c3 a.2.dina_k0
dina_k1:'text', //leaf c4 a.2.dina_k1
},
'int4', //leaf c5 a.3
'json' //leaf c6 a.4
],
dd: { //non_leaf d : [c7,c8,c9,c10,c11]
k0:'int8', //leaf c7 d.k0
k1:'buf', //leaf c8 d.k1
aind: [ //non_leaf d.aind : [c9,c10,c11]
'text', //leaf c9 a.aind.0
'text', //leaf c10 a.aind.1
'json' //leaf c11 a.aind.2
]
}
}
console.log("scheme:");
console.dir(jcfg);
var scheme = _scheme.creat(jcfg).scheme;
var cd = `extra`;
var [cond,rslt] = creat_order_by_for_back(cd,scheme,_parser);
console.dir([cond,rslt],{depth:null});
/*
[ true, { cd: [ 'extra', 'ASC' ], hint: Hint { jpl: {}, jlit: {} } } ]
*/
var cd = `aa[2].dina_k1`;
var [cond,rslt] = creat_order_by_for_back(cd,scheme,_parser);
console.dir([cond,rslt],{depth:null});
/*
[ true, { cd: [ 'c4', 'DESC' ], hint: Hint { jpl: {}, jlit: {} } } ]
*/
var cd = `aa[2].dina_k1,DESC`;
var [cond,rslt] = creat_order_by_for_back(cd,scheme,_parser);
console.dir([cond,rslt],{depth:null});
/*
*/
var cd = `
extra.x : DESC,
extra.y : ASC,
aa[2].dina_k0,
as_json_leaf(dd.aind[2]).x[1]["2"]["x"] : DESC,
as_json_leaf(dd.aind[2]).int,
aa[4],
aa[3] : ASC,
dd.aind[0] : DESC,
aa[0]
`;
var [cond,rslt] = creat_order_by_for_back(cd,scheme,_parser);
console.dir([cond,rslt],{depth:null});
/*
[
true,
{
cd: [
'JPL0', 'DESC', 'JPL1',
'ASC', 'c3', 'ASC',
'JPL2', 'DESC', 'JPL3',
'ASC', 'c6', 'ASC',
'c5', 'ASC', 'c9',
'DESC', 'c1', 'ASC'
],
hint: Hint {
jpl: {
JPL0: [ 'extra', 'x' ],
JPL1: [ 'extra', 'y' ],
JPL2: [ 'c11', 'x', 1, '2', 'x' ],
JPL3: [ 'c11', 'int' ]
},
jlit: {}
}
}
]
*/
METHODS
APIS
{
_vali: {
ERRD: {
unsupported: 'ast type must be Identifier OR SequenceExpression'
},
is_nd_safe: [Function: is_nd_safe]
},
creat_order_by_for_back: [Function: creat_order_by_for_back]
}
LICENSE
- ISC