Sha256: dc991611c97678f8f6648a71ae88580e484b86fd61a498413f73e08ed577d892

Contents?: true

Size: 902 Bytes

Versions: 15

Compression:

Stored size: 902 Bytes

Contents

CREATE OR REPLACE FUNCTION message_store.get_last_stream_message(
  stream_name varchar
)
RETURNS SETOF message_store.message
AS $$
DECLARE
  _command text;
BEGIN
  _command := '
    SELECT
      id::varchar,
      stream_name::varchar,
      type::varchar,
      position::bigint,
      global_position::bigint,
      data::varchar,
      metadata::varchar,
      time::timestamp
    FROM
      messages
    WHERE
      stream_name = $1
    ORDER BY
      position DESC
    LIMIT
      1';

  IF current_setting('message_store.debug_get', true) = 'on' OR current_setting('message_store.debug', true) = 'on' THEN
    RAISE NOTICE 'ยป get_last_message';
    RAISE NOTICE 'stream_name ($1): %', get_last_stream_message.stream_name;
    RAISE NOTICE 'Generated Command: %', _command;
  END IF;

  RETURN QUERY EXECUTE _command USING get_last_stream_message.stream_name;
END;
$$ LANGUAGE plpgsql
VOLATILE;

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
message-db-2.1.6 database/functions/get-last-stream-message.sql
message-db-2.1.5 database/functions/get-last-stream-message.sql
message-db-2.1.4 database/functions/get-last-stream-message.sql
message-db-2.1.3 database/functions/get-last-stream-message.sql
message-db-2.1.2 database/functions/get-last-stream-message.sql
message-db-2.1.1 database/functions/get-last-stream-message.sql
message-db-2.1.0 database/functions/get-last-stream-message.sql
message-db-2.0.2 database/functions/get-last-stream-message.sql
message-db-2.0.1 database/functions/get-last-stream-message.sql
message-db-2.0.0 database/functions/get-last-stream-message.sql
message-db-1.1.3 database/functions/get-last-stream-message.sql
message-db-1.1.2 database/functions/get-last-stream-message.sql
message-db-1.1.1 database/functions/get-last-stream-message.sql
message-db-1.1.0 database/functions/get-last-stream-message.sql
message-db-1.0.0 database/functions/get-last-stream-message.sql