-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcreate-table.ts
43 lines (39 loc) · 855 Bytes
/
create-table.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* This example will generate the big query table from the structure of the schema field in options.
* deep nested fields will be translated to a flat string representation with "_" delimiter.
*/
import {WinstonBigQuery} from '../';
import winston from 'winston';
import {delay} from '../commons/delay';
const logger = winston.createLogger({
level: 'debug',
transports: [
new WinstonBigQuery({
dataset: 'logs',
table: 'my_winston_logs',
schema: {
timestamp: 'timestamp',
firstName: 'string',
lastName: 'string',
session: {
userId: 'integer'
}
},
create: true
})
]
});
(async () => {
try {
await delay(3 * 1000);
logger.debug('Round kick from chuck! Bam!', {
session: {
userId: 1
},
firstName: 'chuck',
lastName: 'norris'
});
} catch (error) {
console.log(error);
}
})();