'How to Insert with a Select using Node-Postgres

In SQL and using postgressql this is a valid query, embedding a SELECT inside an INSERT -

INSERT INTO minute_registers_main_values (registers_id, t, v, i, w, pf, f) 
(
  SELECT id AS registers_id, '2015-09-01T16:34:02', 1.0, 9.1, 5.4, 1.3, 60.01 
  FROM registers WHERE main=TRUE AND cnt=0 AND hub_serial='ni1uiv'
);

I can insert a Foreign Key by doing a Select Lookup on the Insert without having to look up that other ID first.

In node-postgres, in order to INSERT many queries at once, I've turned to pg-format.

  const register_categoriesInsert = `
      INSERT INTO register_categories (register_id, category_id) VALUES %L
    `;

    await client.query(format(register_categoriesInsert, solar_ids.concat(main_ids).concat(all_other_ids)),[], (err, result)=>{
      console.log(err);
      console.log(result);
    });

This allows you to insert many values at once off of one query call. Though I have my questions about pg-format -- it doesn't seem to use parameterization.

I'm trying to do both a large number of inserts and to take advantage of using SELECTS within an INSERT.

Can I do this using node-postgres?



Solution 1:[1]

Bergi above is right.

  INSERT INTO minute_registers_main_values (registers_id, t, v, i, w, pf, f) 
  (
    SELECT id AS registers_id, $1, $2, $3, $4, $5, $6 
    FROM registers WHERE main=$7 AND cnt=$8 AND hub_serial=$9
  );

can be sent into client.query with a multidimensional array of args

Solution 2:[2]

It's because of the font. You cannot do probably anything and strokes on this font will be like on your img. But if you use text-shadow instead of -webkit-text-stroke, it's hack a little bit, but it should work. The main cons is that the text cannot be transparent, because of shaddows, they will be visible, so you must set color of the text.

.cleartext {
  color: #fff;
  text-shadow: 1px 1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, -1px -1px 0 #000, 1px 0px 0 #000, 0px 1px 0 #000, -1px 0px 0 #000, 0px -1px 0 #000;
}

.gbtext {
    font-weight: 700;
}
<h1><span class="cleartext gbtext">It's clear</span> when you blah blah blah.</h1>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Samuel Krempaský