mql2
Advanced tools
Comparing version 0.1.20 to 1.0.0
36
mql.js
import { | ||
is_string, is_function, flatten, flatten as cat, reduce, tap, go, pipe, | ||
map, filter, reject, pluck, uniq, each, index_by, group_by, uniqueBy, object, curry | ||
is_string, is_function, | ||
deep_flat, | ||
go, pipe, tap, | ||
map, filter, reduce, reject, | ||
pluck, uniq, each, index_by, group_by, unique_by, object, curry, min_by, | ||
C | ||
} from 'fxjs2'; | ||
import pg from 'pg'; | ||
@@ -28,7 +33,4 @@ import mysql from 'mysql'; | ||
const minBy = (f, arr) => arr.reduce((a, b) => f(a) <= f(b) ? a : b); | ||
const uniq_index_by = curry((f, coll) => index_by(f, unique_by(f, coll))); | ||
const cmap = curry((f, arr) => Promise.all(arr.map(f))); | ||
const uniq_index_by = curry((f, coll) => index_by(f, uniqueBy(f, coll))); | ||
const first = a => a && a[0]; | ||
@@ -93,7 +95,7 @@ const last = a => a && a[a.length - 1]; | ||
const splited = flatten(strs.map(str => str.split('\n'))) | ||
const splited = deep_flat(strs.map(str => str.split('\n'))) | ||
.filter(str => str.match(/^\s*/)[0]) | ||
.filter(str => str.trim()); | ||
const min = minBy(str => str.match(/^\s*/)[0].length, splited); | ||
const min = min_by(str => str.match(/^\s*/)[0].length, splited); | ||
const a = '\n' + min.match(/^\s*/)[0]; | ||
@@ -119,3 +121,3 @@ | ||
return [ | ||
flatten(strs2).filter(str => str.trim()).reduce((strs, str, i) => { | ||
deep_flat(strs2).filter(str => str.trim()).reduce((strs, str, i) => { | ||
if (i == 0) return strs.push(str), strs; | ||
@@ -131,3 +133,3 @@ const splited = last(strs).split('\n'); | ||
}, []), | ||
flatten(tails2)]; | ||
deep_flat(tails2)]; | ||
} | ||
@@ -186,6 +188,6 @@ | ||
return res; | ||
}, queries, { | ||
}, { | ||
text: '', | ||
values: [] | ||
}); | ||
}, queries); | ||
query.text = query.text.replace(/\n/g, ' ').replace(/\s\s*/g, ' ').trim(); | ||
@@ -202,3 +204,3 @@ return query; | ||
map(Object.keys), | ||
flatten, | ||
deep_flat, | ||
uniq); | ||
@@ -220,3 +222,3 @@ | ||
.join('), (')})`, | ||
values: flatten(values.map(v => v.filter(v => v != SymbolDefault))) | ||
values: deep_flat(values.map(v => v.filter(v => v != SymbolDefault))) | ||
} | ||
@@ -279,3 +281,3 @@ }); | ||
).join(', ')})`, | ||
values: cat(values) | ||
values: deep_flat(values) | ||
}; | ||
@@ -325,3 +327,3 @@ } | ||
ready_sqls(strs, tails), | ||
cat, | ||
deep_flat, | ||
filter(t => t.as), | ||
@@ -372,3 +374,3 @@ each(option => { | ||
function recur([lefts, option]) { | ||
return lefts.length && option.rels.length && go(option.rels, cmap(async function(me) { | ||
return lefts.length && option.rels.length && go(option.rels, C.map(async function(me) { | ||
const query = me.query(); | ||
@@ -375,0 +377,0 @@ if (query && query.text) query.text = query.text.replace(/^\s*WHERE/i, 'AND'); |
{ | ||
"name": "mql2", | ||
"version": "0.1.20", | ||
"version": "1.0.0", | ||
"description": "query builder", | ||
@@ -39,3 +39,3 @@ "main": "index.js", | ||
"esm": "^3.0.80", | ||
"fxjs2": "0.0.4", | ||
"fxjs2": "0.0.17", | ||
"mysql": "^2.16.0", | ||
@@ -42,0 +42,0 @@ "pg": "^7.4.3", |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
665
0
37287
+ Addedfxjs2@0.0.17(transitive)
- Removedfxjs2@0.0.4(transitive)
Updatedfxjs2@0.0.17