1.0.0 • Published 2 years ago

pg-mem-uuid-ossp v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

uuid-ossp extension for pg-mem

Installation

Using npm:

$ {sudo -H} npm i -g npm
$ npm i --save pg-mem-uuid-ossp

Usage

In Node.js:

var { newDb } = require('pg-mem');
var { uuidOssp } = require('pg-mem-uuid-ossp');

With typescript:

import { newDb } from 'pg-mem';
import { uuidOssp } from 'pg-mem-uuid-ossp';

Then use it:

const db = newDb();
db.registerExtension('uuid-ossp', uuidOssp);
...
db.public.many(`
  create extension "uuid-ossp";
  select uuid_generate_v4();
`);

Functions defined

This extension intends to emulate the PostgreSQL uuid-ossp extension, so it defines the following functions:

Functions for UUID Generation

  • uuid_generate_v1() -> uuid
  • uuid_generate_v1mc() -> uuid (synonym for uuid_generate_v1)
  • uuid_generate_v3(namespace uuid, name text) -> uuid
  • uuid_generate_v4() ->
  • uuid_generate_v5(namespace uuid, name text) -> uuid

Functions returning UUID Constants

The RFC4122 defines 4 UUID namespaces that PostgreSQL uuid-ossp extension returns in the following 4 functions:

  • uuid_ns_dns() -> uuid
  • uuid_ns_url() -> uuid
  • uuid_ns_oid() -> uuid
  • uuid_ns_x500() -> uuid

That RFC also defines a Nil UUID:

  • uuid_nil() -> uuid