Skip to content

Instantly share code, notes, and snippets.

@tkreis
Last active July 8, 2016 19:57
Show Gist options
  • Save tkreis/cb5a5c471a405772771fadfae06ba216 to your computer and use it in GitHub Desktop.
Save tkreis/cb5a5c471a405772771fadfae06ba216 to your computer and use it in GitHub Desktop.
Transform base64 encoded id as uuid
CREATE OR REPLACE FUNCTION decode_uuid(encoded_uuid text) RETURNS uuid AS $$
BEGIN
RETURN uuid(encode(decode((encoded_uuid || '==') ,'base64'), 'hex'));
END;
$$ LANGUAGE plpgsql;
-- usage
SELECT * from ditto_entity where id = decode_uuid('mttF0tAFSbq1of1oFNfAJw');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment