-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Elin Angelow
committed
Dec 19, 2023
1 parent
720bfb8
commit fdbf17d
Showing
8 changed files
with
87 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
# Expose sql methods as nodejs methods | ||
|
||
## arguments | ||
|
||
- every method that is called should consist on only 1 argument | ||
of type object, in it should be passed every argument of sql function,procedure ... etc | ||
|
||
- mssql: ok | ||
- mysql: pending | ||
- postgres: pending | ||
- postgres: wip | ||
- sqlite: pending | ||
|
||
[![Build Status](https://travis-ci.com/zetxx/expose-sql-methods.svg?branch=master)](https://travis-ci.com/zetxx/expose-sql-methods) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,33 @@ | ||
CREATE TABLE "some-test-example"."exsschema"."tx" ( | ||
CREATE TABLE "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)) | ||
INSERT INTO "exsschema".tx (device,created) VALUES | ||
('34987a479f90',1702857600), | ||
('ec62608a3368',1702857600), | ||
('34987a479f90',1702894599), | ||
('ec62608a3368',1702894609), | ||
('34987a479f90',1702894784), | ||
('ec62608a3368',1702894804), | ||
('34987a479f90',1702894968), | ||
('ec62608a3368',1702894988), | ||
('34987a479f90',1702895168), | ||
('ec62608a3368',1702895182); | ||
--------------------------------------------------------------- | ||
CREATE FUNCTION "exsschema"."fnLastTx"("pDevice" VARCHAR (100)) | ||
RETURNS table (tag integer, created BIGINT) | ||
AS | ||
$$ | ||
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); | ||
SELECT tag, created FROM "exsschema"."tx" WHERE tag = (SELECT MAX(tag) AS tag FROM "exsschema"."tx" WHERE device = "pDevice"); | ||
$$ | ||
LANGUAGE sql; | ||
--------------------------------------------------------------- | ||
CREATE FUNCTION "some-test-example"."exsschema"."fnNewTx"(pDevice VARCHAR (100), pCreated BIGINT) | ||
CREATE FUNCTION "fnNewTx"(pDevice VARCHAR (100), pCreated BIGINT) | ||
RETURNS table (tag integer, created BIGINT) | ||
AS | ||
$$ | ||
INSERT INTO "some-test-example"."exsschema"."tx" (device, created) VALUES (pDevice, pCreated) RETURNING tag, created; | ||
SELECT 1 tag, 2 created RETURNING tag, created; | ||
$$ | ||
LANGUAGE sql; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters