Skip to content

Commit

Permalink
Adding functions to postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
bgelatti committed Nov 7, 2024
1 parent e1cdf8c commit 060c718
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 10 deletions.
19 changes: 14 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/mysql/src/Helpers/DeviceDatabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export async function getDeviceConnection(id: TGenericID, type: TDeviceType) {
table.timestamp("created_at").nullable();
table.timestamp("chunk_timestamp_start");
table.timestamp("chunk_timestamp_end");
table.string("serie", 100);

if (type === "mutable") {
table.timestamp("updated_at");
Expand All @@ -32,7 +33,6 @@ export async function getDeviceConnection(id: TGenericID, type: TDeviceType) {
table.index(["time"]);
table.index(["group"]);
table.index(["created_at"]);
table.string("serie", 100);
});
}

Expand Down
3 changes: 2 additions & 1 deletion plugins/postgres/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
},
"dependencies": {
"knex": "3.1.0",
"pg": "8.13.0"
"pg": "8.13.1",
"pg-copy-streams": "6.0.6"
},
"devDependencies": {
"@types/pg": "8.11.10"
Expand Down
4 changes: 4 additions & 0 deletions plugins/postgres/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ import getHourlyStatistics from "./Providers/Statistic/getHourlyStatistics.ts";
import getSummary from "./Providers/Summary/getSummary.ts";
import getTagKeys from "./Providers/Tag/getTagKeys.ts";
import configs from "./settings.ts";
import exportDeviceData from "./Providers/DeviceData/exportDeviceData.ts";
import importDeviceData from "./Providers/DeviceData/importDeviceData.ts";

export const postgreSQL = new DatabaseModule({
id: "PostgreSQL",
Expand Down Expand Up @@ -135,3 +137,5 @@ postgreSQL.getSummary = getSummary;
postgreSQL.getTagKeys = getTagKeys;
postgreSQL.setDeviceParams = setDeviceParams;
postgreSQL.setPluginStorageItem = setPluginStorageItem;
postgreSQL.exportDeviceData = exportDeviceData;
postgreSQL.importDeviceData = importDeviceData;
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import fs from "node:fs";
import { Stream } from "node:stream";
import type { TDeviceType, TGenericID } from "@tago-io/tcore-sdk/types";
import { stringify } from "csv";
import { getDeviceConnection } from "../../Helpers/DeviceDatabase.ts";
Expand Down
2 changes: 0 additions & 2 deletions plugins/sqlite/src/Providers/DeviceData/importDeviceData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ async function _insertData(client: Knex, data: any[]) {
return;
})
.catch((error) => {
console.log(error);
Promise.reject(error);
});
}
Expand Down Expand Up @@ -48,7 +47,6 @@ async function importDeviceData(
resolve("Data imported successfully");
})
.on("error", (error) => {
console.log(error);
reject(error);
});
});
Expand Down

0 comments on commit 060c718

Please sign in to comment.