pg-mem-uuid-ossp
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

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

Package Sidebar

Install

npm i pg-mem-uuid-ossp

Weekly Downloads

124

Version

1.0.0

License

MIT

Unpacked Size

7.17 kB

Total Files

7

Last publish

Collaborators

  • wpomier