Skip to content

Commit

Permalink
fix: init
Browse files Browse the repository at this point in the history
  • Loading branch information
Elin Angelow committed Dec 18, 2023
1 parent 8b522df commit 20db663
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 32 deletions.
2 changes: 1 addition & 1 deletion examples/postgresql/example.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ module.exports = {
},
link: {
gluePrefix: '.',
schema: ['a', 'b'] // schemas allowed
schema: ['public'] // schemas allowed
}
};
49 changes: 19 additions & 30 deletions examples/postgresql/example.sql
Original file line number Diff line number Diff line change
@@ -1,32 +1,21 @@
CREATE TYPE LessonType AS TABLE (LessonId INT, LessonName VARCHAR(100))

CREATE TABLE Lesson (
Id INT PRIMARY KEY,
LName VARCHAR(50)
)
-------------------------
CREATE PROCEDURE Usp_InsertLesson
@ParLessonType LessonType READONLY,
@ParLessonType2 LessonType READONLY
CREATE TABLE "some-test-example"."exsschema"."tx" (
tag serial PRIMARY KEY,
device VARCHAR (100) NOT NULL,
created BIGINT DEFAULT extract(epoch from now())
);
---------------------------------------------------------------
CREATE FUNCTION "some-test-example"."exsschema"."fnLastTx"(pDevice VARCHAR (100))
RETURNS table (tag integer, created BIGINT)
AS
INSERT INTO Lesson
SELECT * FROM @ParLessonType;

CREATE PROCEDURE Usp_InsertLesson2
@ParLessonType LessonType READONLY,
@ParLessonType2 LessonType READONLY
$$
SELECT tag, created FROM "some-test-example"."exsschema"."tx" WHERE tag = (SELECT MAX(tag) AS tag FROM "some-test-example"."exsschema"."tx" WHERE device = pDevice);
$$
LANGUAGE sql;
---------------------------------------------------------------
CREATE FUNCTION "some-test-example"."exsschema"."fnNewTx"(pDevice VARCHAR (100), pCreated BIGINT)
RETURNS table (tag integer, created BIGINT)
AS
INSERT INTO Lesson
SELECT * FROM @ParLessonType
-------------------------
DECLARE @VarLessonType AS LessonType

INSERT INTO @VarLessonType VALUES ( 1, 'Math')
INSERT INTO @VarLessonType VALUES ( 2, 'Science')
INSERT INTO @VarLessonType VALUES ( 3, 'Geometry')


EXECUTE Usp_InsertLesson @VarLessonType
-------------------------
-------------------------
-------------------------
$$
INSERT INTO "some-test-example"."exsschema"."tx" (device, created) VALUES (pDevice, pCreated) RETURNING tag, created;
$$
LANGUAGE sql;
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
},
"dependencies": {
"error": "^10.4.0",
"mssql": "10.0.1"
"mssql": "10.0.1",
"postgres": "3.4.3"
},
"devDependencies": {
"tap": "*",
Expand Down

0 comments on commit 20db663

Please sign in to comment.