New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@db-auto/postgres

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@db-auto/postgres - npm Package Compare versions

Comparing version 0.0.29 to 0.0.30

dist/src/pgMeta.d.ts

4

dist/src/pgDal.js

@@ -15,2 +15,3 @@ "use strict";

const utils_1 = require("@db-auto/utils");
const pgMeta_1 = require("./pgMeta");
function postgresOpen(env) {

@@ -56,3 +57,4 @@ if (env.type !== 'postgres')

update: postgresDalUpdate(pool),
close: () => postgresClose(pool)
close: () => postgresClose(pool),
metaData: (0, pgMeta_1.pgMeta)(pool, 'public')
};

@@ -59,0 +61,0 @@ }

@@ -16,2 +16,3 @@ "use strict";

const dal = (0, pgDal_1.postgresDal)(env);
afterAll(() => dal.close());
describe('pgDal', () => {

@@ -21,40 +22,148 @@ it("should create tables, insert to the them and read from them", () => __awaiter(void 0, void 0, void 0, function* () {

return;
try {
yield dal.update("drop table if exists drivertable");
yield dal.update("drop table if exists mission");
yield dal.update("drop table if exists driver_aud");
yield dal.update("drop table if exists mission_aud");
yield dal.update("create table if not exists drivertable (driverId int, name text)");
yield dal.update("create table if not exists mission (id int, driverId int)");
yield dal.update("create table if not exists driver_aud (id int,who text, what text)");
yield dal.update("create table if not exists mission_aud (id int, who text, what text)");
yield dal.update("insert into drivertable (driverId, name) values ($1, $2)", 1, "phil");
yield dal.update("insert into drivertable (driverId, name) values ($1, $2)", 2, "joe");
yield dal.update("insert into mission (id, driverId) values ($1, $2)", 1, 1);
yield dal.update("insert into mission (id, driverId) values ($1, $2)", 2, 2);
yield dal.update("insert into driver_aud (id, who, what) values ($1, $2, $3)", 1, "phil", "insert1");
yield dal.update("insert into driver_aud (id, who, what) values ($1, $2, $3)", 2, "phil", "insert2");
yield dal.update("insert into mission_aud (id, who, what) values ($1, $2, $3)", 1, "phil", "insert");
const res = yield dal.query("select * from drivertable");
expect(res.rows).toEqual([
{
"driverid": 1,
"name": "phil"
yield dal.update("drop table if exists drivertable cascade");
yield dal.update("drop table if exists mission cascade");
yield dal.update("drop table if exists driver_aud cascade");
yield dal.update("drop table if exists mission_aud cascade");
yield dal.update("create table if not exists drivertable (driverId int, name text)");
yield dal.update("create table if not exists mission (id int, driverId int, mission text)");
yield dal.update("create table if not exists driver_aud (id int,who text, what text)");
yield dal.update("create table if not exists mission_aud (id int, who text, what text)");
yield dal.update(`alter table driverTable
add constraint pk_driver primary key (driverId);`);
yield dal.update(`alter table mission
add constraint pk_mission primary key (id);`);
yield dal.update(`ALTER TABLE mission
ADD CONSTRAINT fk_mission_driver FOREIGN KEY (driverId) REFERENCES drivertable (driverId);`);
yield dal.update(`alter table driver_aud drop constraint if exists fk_driver_aud_driver;`);
yield dal.update(`ALTER TABLE driver_aud
ADD CONSTRAINT fk_driver_aud_driver FOREIGN KEY (id) REFERENCES drivertable (driverId);`);
yield dal.update(`alter table mission_aud
add constraint fk_mission_aud_mission foreign key (id) references mission (id);`);
yield dal.update("insert into drivertable (driverId, name) values ($1, $2)", 1, "phil");
yield dal.update("insert into drivertable (driverId, name) values ($1, $2)", 2, "joe");
yield dal.update("insert into mission (id, driverId, mission) values ($1, $2, $3)", 1, 1, "m1");
yield dal.update("insert into mission (id, driverId, mission) values ($1, $2, $3)", 2, 2, "m2");
yield dal.update("insert into driver_aud (id, who, what) values ($1, $2, $3)", 1, "phil", "insert1");
yield dal.update("insert into driver_aud (id, who, what) values ($1, $2, $3)", 2, "phil", "insert2");
yield dal.update("insert into mission_aud (id, who, what) values ($1, $2, $3)", 1, "phil", "insert");
const res = yield dal.query("select * from drivertable");
expect(res.rows).toEqual([
{
"driverid": 1,
"name": "phil"
},
{
"driverid": 2,
"name": "joe"
}
]);
expect(res.meta).toEqual({
"columns": [
{ "name": "driverid" },
{ "name": "name" }
]
});
}));
it("should extract metadata", () => __awaiter(void 0, void 0, void 0, function* () {
if (inCi)
return;
const res = yield dal.metaData();
expect(res).toEqual({
"tables": {
"driver_aud": {
"columns": {
"id": {
"type": "integer"
},
"what": {
"type": "text"
},
"who": {
"type": "text"
}
},
"fk": {
"fk_driver_aud_driver": {
"column": "id",
"raw": "FOREIGN KEY (id) REFERENCES drivertable(driverid)",
"refColumn": "driverid",
"refTable": "drivertable"
}
}
},
{
"driverid": 2,
"name": "joe"
"drivertable": {
"columns": {
"driverid": {
"type": "integer"
},
"name": {
"type": "text"
}
},
"fk": {
"fk_driver_aud_driver": {
"column": "driverid",
"raw": "FOREIGN KEY (id) REFERENCES drivertable(driverid) reversed",
"refColumn": "id",
"refTable": "driver_aud"
},
"fk_mission_driver": {
"column": "driverid",
"raw": "FOREIGN KEY (driverid) REFERENCES drivertable(driverid) reversed",
"refColumn": "driverid",
"refTable": "mission"
}
}
},
"mission": {
"columns": {
"driverid": {
"type": "integer"
},
"id": {
"type": "integer"
},
"mission": {
"type": "text"
}
},
"fk": {
"fk_mission_aud_mission": {
"column": "id",
"raw": "FOREIGN KEY (id) REFERENCES mission(id) reversed",
"refColumn": "id",
"refTable": "mission_aud"
},
"fk_mission_driver": {
"column": "driverid",
"raw": "FOREIGN KEY (driverid) REFERENCES drivertable(driverid)",
"refColumn": "driverid",
"refTable": "drivertable"
}
}
},
"mission_aud": {
"columns": {
"id": {
"type": "integer"
},
"what": {
"type": "text"
},
"who": {
"type": "text"
}
},
"fk": {
"fk_mission_aud_mission": {
"column": "id",
"raw": "FOREIGN KEY (id) REFERENCES mission(id)",
"refColumn": "id",
"refTable": "mission"
}
}
}
]);
expect(res.meta).toEqual({
"columns": [
{ "name": "driverid" },
{ "name": "name" }
]
});
}
finally {
dal.close();
}
}
});
}));
});
{
"name": "@db-auto/postgres",
"description": "",
"version": "0.0.29",
"version": "0.0.30",
"main": "dist/index",

@@ -21,4 +21,4 @@ "types": "dist/index",

"pg": "^8.10.0",
"@db-auto/utils": "0.0.29",
"@db-auto/dal": "0.0.29"
"@db-auto/utils": "0.0.30",
"@db-auto/dal": "0.0.30"
},

@@ -25,0 +25,0 @@ "devDependencies": {

@@ -1,1 +0,20 @@

Postgres database abstraction layer for db-auto
Postgres database abstraction layer for db-auto
Useful links
https://www.postgresql.org/docs/current/information-schema.html
# Tables:
SELECT table_name FROM information_schema.tables WHERE table_schema = 'public';
# Columns
https://www.postgresql.org/docs/current/infoschema-columns.html
SELECT *
FROM information_schema.columns
WHERE table_schema = 'your_schema'
AND table_name = 'your_table' ;
Good columns:
column_name
data_type
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