Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@triptease/pg-history-db

Package Overview
Dependencies
Maintainers
5
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@triptease/pg-history-db - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

21

CHANGELOG.md

@@ -5,19 +5,28 @@ # Change Log

<a name="0.3.0"></a>
# [0.3.0](https://github.com/triptease/pg-history-db/compare/v0.2.0...v0.3.0) (2019-01-09)
### Bug Fixes
- store timestamp with timezone ([4264b1e](https://github.com/triptease/pg-history-db/commit/4264b1e))
### Features
- Added ability to retrieve lastest version of all entries with a specific condition ([80a2030](https://github.com/triptease/pg-history-db/commit/80a2030))
<a name="0.2.0"></a>
# [0.2.0](https://github.com/triptease/pg-history-db/compare/v0.1.0...v0.2.0) (2018-11-28)
### improvement
* types the input and output to the exported functions ([bd51c2e](https://github.com/triptease/pg-history-db/commit/bd51c2e))
- types the input and output to the exported functions ([bd51c2e](https://github.com/triptease/pg-history-db/commit/bd51c2e))
### BREAKING CHANGES
* `id` has been rename to `entityId`
- `id` has been rename to `entityId`
<a name="0.1.0"></a>
# 0.1.0 (2018-11-16)

@@ -7,3 +7,6 @@ declare type EntityId = string;

};
declare type RetrieveBody = InsertBody & {
declare type RetrieveBody = {
entityId: EntityId;
userId: string;
data: any;
timestamp: Date;

@@ -15,2 +18,3 @@ version: number;

export declare const retrieveHistory: (id: string) => Promise<RetrieveBody[]>;
export declare const retrieveAll: (where: string) => Promise<RetrieveBody[]>;
export {};

@@ -1,2 +0,2 @@

var r,t=require("pg"),n=(r=require("uuid"))&&"object"==typeof r&&"default"in r?r.default:r;const e=r=>new Promise(function(n,e){var u=function(r){try{return console.error(r),n(Promise.reject(r))}catch(r){return e(r)}};try{let e,i;return(e=new t.Client).connect().then(function(t){try{return e.query("\n SELECT *\n FROM objects\n WHERE group_id=$1\n AND version=(\n SELECT max(version)\n FROM objects\n WHERE group_id=$1\n )\n",[r]).then(function(r){try{return i=r,e.end().then(function(r){try{return n({entityId:i.rows[0].group_id,userId:i.rows[0].user_id,timestamp:i.rows[0].timestamp,version:i.rows[0].version,data:i.rows[0].data})}catch(r){return u(r)}},u)}catch(r){return u(r)}},u)}catch(r){return u(r)}},u)}catch(r){u(r)}});exports.insert=(r=>new Promise(function(u,i){var o=function(r){try{return console.error(r),u(Promise.reject(r))}catch(r){return i(r)}};try{let i,c;return(i=new t.Client).connect().then(function(t){try{if(c=r.entityId||n.v4(),r.entityId)return i.query("\n INSERT INTO objects\n (group_id, user_id, version, data)\n values\n ($1, $2, (\n SELECT max(version)+1\n FROM objects\n WHERE group_id=$1\n ), $3)\n",[c,r.userId,r.data]).then(function(r){try{return s.call(this)}catch(r){return o(r)}}.bind(this),o);{let t;return i.query("\n INSERT INTO objects\n (group_id, user_id, version, data)\n values\n ($1, $2, $3, $4)\n",[c,r.userId,t=1,r.data]).then(function(r){try{return s.call(this)}catch(r){return o(r)}}.bind(this),o)}function s(){return i.end().then(function(r){try{return e(c).then(u,o)}catch(r){return o(r)}},o)}}catch(r){return o(r)}}.bind(this),o)}catch(r){o(r)}})),exports.retrieve=e,exports.retrieveHistory=(r=>new Promise(function(n,e){var u=function(r){try{return console.error(r),n(Promise.reject(r))}catch(r){return e(r)}};try{let e,i,o;return(e=new t.Client).connect().then(function(t){try{return e.query("\n SELECT *\n FROM objects\n WHERE group_id=$1\n ORDER BY version ASC\n",[r]).then(function(r){try{return i=r,e.end().then(function(r){try{return o=i.rows.map(r=>({id:r.group_id,userId:r.user_id,timestamp:r.timestamp,version:r.version,data:r.data})),n(o)}catch(r){return u(r)}},u)}catch(r){return u(r)}},u)}catch(r){return u(r)}},u)}catch(r){u(r)}}));
var t,n=require("pg"),e=(t=require("uuid"))&&"object"==typeof t&&"default"in t?t.default:t;const r=t=>new Promise(function(e,r){var i=function(t){try{return console.error(t),e(Promise.reject(t))}catch(t){return r(t)}};try{let r,c;return(r=new n.Client).connect().then(function(n){try{return r.query("\n SELECT *\n FROM objects\n WHERE entity_id=$1\n AND version=(\n SELECT max(version)\n FROM objects\n WHERE entity_id=$1\n )\n",[t]).then(function(t){try{return c=t,r.end().then(function(t){try{return e({entityId:c.rows[0].entity_id,userId:c.rows[0].user_id,timestamp:c.rows[0].timestamp,version:c.rows[0].version,data:c.rows[0].data})}catch(t){return i(t)}},i)}catch(t){return i(t)}},i)}catch(t){return i(t)}},i)}catch(t){i(t)}});exports.insert=(t=>new Promise(function(i,c){var u=function(t){try{return console.error(t),i(Promise.reject(t))}catch(t){return c(t)}};try{let c,o;return(c=new n.Client).connect().then(function(n){try{if(o=t.entityId||e.v4(),t.entityId)return c.query("\n INSERT INTO objects\n (entity_id, user_id, version, data)\n values\n ($1, $2, (\n SELECT max(version)+1\n FROM objects\n WHERE entity_id=$1\n ), $3)\n",[o,t.userId,t.data]).then(function(t){try{return s.call(this)}catch(t){return u(t)}}.bind(this),u);{let n;return c.query("\n INSERT INTO objects\n (entity_id, user_id, version, data)\n values\n ($1, $2, $3, $4)\n",[o,t.userId,n=1,t.data]).then(function(t){try{return s.call(this)}catch(t){return u(t)}}.bind(this),u)}function s(){return c.end().then(function(t){try{return r(o).then(i,u)}catch(t){return u(t)}},u)}}catch(t){return u(t)}}.bind(this),u)}catch(t){u(t)}})),exports.retrieve=r,exports.retrieveHistory=(t=>new Promise(function(e,r){var i=function(t){try{return console.error(t),e(Promise.reject(t))}catch(t){return r(t)}};try{let r,c,u;return(r=new n.Client).connect().then(function(n){try{return r.query("\n SELECT *\n FROM objects\n WHERE entity_id=$1\n ORDER BY version ASC\n",[t]).then(function(t){try{return c=t,r.end().then(function(t){try{return u=c.rows.map(t=>({entityId:t.entity_id,userId:t.user_id,timestamp:t.timestamp,version:t.version,data:t.data})),e(u)}catch(t){return i(t)}},i)}catch(t){return i(t)}},i)}catch(t){return i(t)}},i)}catch(t){i(t)}}));
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("pg"),require("uuid")):"function"==typeof define&&define.amd?define(["exports","pg","uuid"],n):n(t.pgHistoryDb={},t.pg,t.uuid)}(this,function(t,n,r){r=r&&r.hasOwnProperty("default")?r.default:r;const e=t=>new Promise(function(r,e){var u=function(t){try{return console.error(t),r(Promise.reject(t))}catch(t){return e(t)}};try{let e,i;return(e=new n.Client).connect().then(function(n){try{return e.query("\n SELECT *\n FROM objects\n WHERE group_id=$1\n AND version=(\n SELECT max(version)\n FROM objects\n WHERE group_id=$1\n )\n",[t]).then(function(t){try{return i=t,e.end().then(function(t){try{return r({entityId:i.rows[0].group_id,userId:i.rows[0].user_id,timestamp:i.rows[0].timestamp,version:i.rows[0].version,data:i.rows[0].data})}catch(t){return u(t)}},u)}catch(t){return u(t)}},u)}catch(t){return u(t)}},u)}catch(t){u(t)}});t.insert=(t=>new Promise(function(u,i){var o=function(t){try{return console.error(t),u(Promise.reject(t))}catch(t){return i(t)}};try{let i,c;return(i=new n.Client).connect().then(function(n){try{if(c=t.entityId||r.v4(),t.entityId)return i.query("\n INSERT INTO objects\n (group_id, user_id, version, data)\n values\n ($1, $2, (\n SELECT max(version)+1\n FROM objects\n WHERE group_id=$1\n ), $3)\n",[c,t.userId,t.data]).then(function(t){try{return s.call(this)}catch(t){return o(t)}}.bind(this),o);{let n;return i.query("\n INSERT INTO objects\n (group_id, user_id, version, data)\n values\n ($1, $2, $3, $4)\n",[c,t.userId,n=1,t.data]).then(function(t){try{return s.call(this)}catch(t){return o(t)}}.bind(this),o)}function s(){return i.end().then(function(t){try{return e(c).then(u,o)}catch(t){return o(t)}},o)}}catch(t){return o(t)}}.bind(this),o)}catch(t){o(t)}})),t.retrieve=e,t.retrieveHistory=(t=>new Promise(function(r,e){var u=function(t){try{return console.error(t),r(Promise.reject(t))}catch(t){return e(t)}};try{let e,i,o;return(e=new n.Client).connect().then(function(n){try{return e.query("\n SELECT *\n FROM objects\n WHERE group_id=$1\n ORDER BY version ASC\n",[t]).then(function(t){try{return i=t,e.end().then(function(t){try{return o=i.rows.map(t=>({id:t.group_id,userId:t.user_id,timestamp:t.timestamp,version:t.version,data:t.data})),r(o)}catch(t){return u(t)}},u)}catch(t){return u(t)}},u)}catch(t){return u(t)}},u)}catch(t){u(t)}}))});
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("pg"),require("uuid")):"function"==typeof define&&define.amd?define(["exports","pg","uuid"],n):n(t.pgHistoryDb={},t.pg,t.uuid)}(this,function(t,n,e){e=e&&e.hasOwnProperty("default")?e.default:e;const r=t=>new Promise(function(e,r){var i=function(t){try{return console.error(t),e(Promise.reject(t))}catch(t){return r(t)}};try{let r,u;return(r=new n.Client).connect().then(function(n){try{return r.query("\n SELECT *\n FROM objects\n WHERE entity_id=$1\n AND version=(\n SELECT max(version)\n FROM objects\n WHERE entity_id=$1\n )\n",[t]).then(function(t){try{return u=t,r.end().then(function(t){try{return e({entityId:u.rows[0].entity_id,userId:u.rows[0].user_id,timestamp:u.rows[0].timestamp,version:u.rows[0].version,data:u.rows[0].data})}catch(t){return i(t)}},i)}catch(t){return i(t)}},i)}catch(t){return i(t)}},i)}catch(t){i(t)}});t.insert=(t=>new Promise(function(i,u){var c=function(t){try{return console.error(t),i(Promise.reject(t))}catch(t){return u(t)}};try{let u,o;return(u=new n.Client).connect().then(function(n){try{if(o=t.entityId||e.v4(),t.entityId)return u.query("\n INSERT INTO objects\n (entity_id, user_id, version, data)\n values\n ($1, $2, (\n SELECT max(version)+1\n FROM objects\n WHERE entity_id=$1\n ), $3)\n",[o,t.userId,t.data]).then(function(t){try{return s.call(this)}catch(t){return c(t)}}.bind(this),c);{let n;return u.query("\n INSERT INTO objects\n (entity_id, user_id, version, data)\n values\n ($1, $2, $3, $4)\n",[o,t.userId,n=1,t.data]).then(function(t){try{return s.call(this)}catch(t){return c(t)}}.bind(this),c)}function s(){return u.end().then(function(t){try{return r(o).then(i,c)}catch(t){return c(t)}},c)}}catch(t){return c(t)}}.bind(this),c)}catch(t){c(t)}})),t.retrieve=r,t.retrieveHistory=(t=>new Promise(function(e,r){var i=function(t){try{return console.error(t),e(Promise.reject(t))}catch(t){return r(t)}};try{let r,u,c;return(r=new n.Client).connect().then(function(n){try{return r.query("\n SELECT *\n FROM objects\n WHERE entity_id=$1\n ORDER BY version ASC\n",[t]).then(function(t){try{return u=t,r.end().then(function(t){try{return c=u.rows.map(t=>({entityId:t.entity_id,userId:t.user_id,timestamp:t.timestamp,version:t.version,data:t.data})),e(c)}catch(t){return i(t)}},i)}catch(t){return i(t)}},i)}catch(t){return i(t)}},i)}catch(t){i(t)}}))});
//# sourceMappingURL=index.umd.js.map
{
"name": "@triptease/pg-history-db",
"version": "0.2.0",
"version": "0.3.0",
"description": "Append-only database driver for PostgreSQL",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc