Update every selected row I have a table in postgresql, let's say users:
CREATE TABLE users(
  user_id bigint NOT NULL,
  username character varying(24) NOT NULL,
  password character varying(64) NOT NULL,
  timestamp_created timestamp with time zone DEFAULT NOW() NOT NULL,
  new boolean DEFAULT FALSE NOT NULL
);

With the following query, I select all users
SELECT * FROM users;

What I want to achieve is the following: when a row is selected, the value of 'new' should be updated from false to true.
There is no BEFORE/AFTER SELECT in postgresql trigger functions, is there something similar?
Edit: I'm using NodeJS. Currently, I store all the user ID's of the returned rows in an array and do this query:
UPDATE users SET new = true WHERE user_id = ANY($1);

$1 is placeholder for the user ID's array.
Is there a more convenient way to do this?
A somewhat complicated way could be
WITH new_users AS (
   UPDATE users SET new = TRUE
   WHERE NOT new RETURNING /* all columns except &quot;new&quot; */
)
 SELECT /* all columns except &quot;new&quot; */
 FROM new_users
UNION
 SELECT /* all columns except &quot;new&quot; */
 FROM users;

The UNION will eliminate duplicates.