How to use the fxjs.pluck 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 / ljoin.js View on Github external
uniq
    ));

  Object.assign(table_columns, await go(
    QUERY `
      SELECT table_name, column_name 
      FROM information_schema.columns 
      WHERE
        table_name in (
          SELECT tablename 
          FROM pg_tables
          WHERE 
            tableowner=${connection_info.user || process.env.PGUSER} 
        ) ORDER BY table_name;`,
    group_by((v) => v.table_name),
    map(v => pluck('column_name', v))),
    await go(QUERY `
      SELECT * 
      FROM INFORMATION_SCHEMA.view_column_usage
      WHERE view_catalog=${connection_info.database || process.env.PGDATABASE}
      ;`,
    group_by((v) => v.view_name),
    map(v => pluck('column_name', v)))
  );

  function where_in_query(left, where_in, QUERY) {
    const colums = uniq(add_column(left).originals.concat(left.key));
    const query = left.query();
    if (query && query.text) query.text = query.text.replace(/^\s*WHERE/i, 'AND');
    return left.row_number.length == 2 ?
      QUERY `
      SELECT *
github marpple / FxSQL / src / index.js View on Github external
const add_column = me =>
    me.column == '*' ?
      COLUMN(me.as + '.*') :
      is_column(me.column) ?
        COLUMN(...go(
          me.column.originals.concat(pluck('left_key', me.rels)),
          map(c => is_string(c) ? me.as + '.' + c : c),
          uniq)) :
        tag(SymbolInjection);
github marpple / FxSQL / src / ljoin.js View on Github external
const add_as_join = (me, as) =>
    COLUMN(...go(
      me.column.originals.concat(pluck('left_key', me.left_joins)),
      map(c => me.as + '.' + c + ' AS ' + `${as}>_<${c}`),
      uniq
    ));