@8ms/helpers 1.2.16 → 1.2.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
type LoadData = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
file: {
|
|
3
|
+
bucket: string;
|
|
4
|
+
key: string;
|
|
5
|
+
metadata: object;
|
|
6
|
+
};
|
|
7
|
+
table: {
|
|
8
|
+
datasetId: string;
|
|
9
|
+
tableId: string;
|
|
10
|
+
};
|
|
7
11
|
};
|
|
8
12
|
/**
|
|
9
13
|
* Load data into a given table.
|
|
10
14
|
*/
|
|
11
|
-
declare const loadData: ({
|
|
15
|
+
declare const loadData: ({ file, table }: LoadData) => Promise<void>;
|
|
12
16
|
export default loadData;
|
|
@@ -7,12 +7,16 @@ const IsTableExists_1 = __importDefault(require("./IsTableExists"));
|
|
|
7
7
|
/**
|
|
8
8
|
* Load data into a given table.
|
|
9
9
|
*/
|
|
10
|
-
const loadData = async ({
|
|
11
|
-
const tableExists = await (0, IsTableExists_1.default)({
|
|
10
|
+
const loadData = async ({ file, table }) => {
|
|
11
|
+
const tableExists = await (0, IsTableExists_1.default)({
|
|
12
|
+
datasetId: table.datasetId,
|
|
13
|
+
tableId: table.tableId,
|
|
14
|
+
});
|
|
12
15
|
if (tableExists) {
|
|
13
|
-
await global.googleBigQueryClient.dataset(datasetId)
|
|
14
|
-
.table(tableId)
|
|
15
|
-
.load(global.googleStorageClient.bucket(bucket)
|
|
16
|
+
await global.googleBigQueryClient.dataset(table.datasetId)
|
|
17
|
+
.table(table.tableId)
|
|
18
|
+
.load(global.googleStorageClient.bucket(file.bucket)
|
|
19
|
+
.file(file.key), file.metadata);
|
|
16
20
|
}
|
|
17
21
|
};
|
|
18
22
|
exports.default = loadData;
|