How to use the fxjs.flat function in fxjs

To help you get started, we’ve selected a few fxjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github marpple / FxSQL / src / index.js View on Github external
return Object.assign(tag(function() {
      let sqls = flat(originals
        .map(v =>
          is_string(v) ? [{ text: columnize(v) }, { text: ', ' }] :
            is_tag(v) ? [v(), { text: ', ' }] :
              [{ text: Object.entries(v).map(v => v.map(dq).join(' AS ')).join(', ')}, { text: ', ' }]));
      sqls.pop();
      return merge_query(sqls, '');
    }), { [SymbolColumn]: true, originals: originals });
  }
github marpple / FxSQL / src / index.js View on Github external
const DEFAULTS = go(
        columns,
        map(k => [k, SymbolDefault]),
        object);

      values = values
        .map(v => Object.assign({}, DEFAULTS, v))
        .map(v => Object.values(v));

      return {
        text: `(${COLUMN(...columns)().text}) VALUES (${
          values
            .map(v => v.map(v => v == SymbolDefault ? 'DEFAULT' : to_q()).join(', '))
            .join('), (')})`,
        values: flat(values.map(v => v.filter(v => v != SymbolDefault)))
      }
    });
  }