pg#types TypeScript Examples

The following examples show how to use pg#types. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: postgres.ts    From Deep-Lynx with MIT License 6 votes vote down vote up
// init will set the connection pool from the configuration file.
    // eslint-disable-next-line @typescript-eslint/require-await
    public async init() {
        this.pool = new Pool({
            connectionString: Config.core_db_connection_string,
        });
        // ensures timestamps returned from the db are in UTC strings to match what is in the db
        types.setTypeParser(1114, (stringValue) => {
            return new Date(Date.parse(stringValue + '+0000'));
        });
    }
Example #2
Source File: database_queue_impl.ts    From Deep-Lynx with MIT License 6 votes vote down vote up
async Init(): Promise<boolean> {
        this.pool = new Pool({
            connectionString: Config.core_db_connection_string,
        });

        // ensures timestamps returned from the db are in UTC strings to match what is in the db
        types.setTypeParser(1114, (stringValue) => {
            return new Date(Date.parse(stringValue + '+0000'));
        });

        return Promise.resolve(true);
    }
Example #3
Source File: db.ts    From postgres-meta with Apache License 2.0 5 votes vote down vote up
types.setTypeParser(types.builtins.INT8, parseInt)
Example #4
Source File: db.ts    From postgres-meta with Apache License 2.0 5 votes vote down vote up
types.setTypeParser(types.builtins.DATE, (x) => x)
Example #5
Source File: db.ts    From postgres-meta with Apache License 2.0 5 votes vote down vote up
types.setTypeParser(types.builtins.TIMESTAMP, (x) => x)
Example #6
Source File: db.ts    From postgres-meta with Apache License 2.0 5 votes vote down vote up
types.setTypeParser(types.builtins.TIMESTAMPTZ, (x) => x)
Example #7
Source File: db.ts    From postgres-meta with Apache License 2.0 5 votes vote down vote up
types.setTypeParser(1115, parseArray)
Example #8
Source File: db.ts    From postgres-meta with Apache License 2.0 5 votes vote down vote up
// _timestamp
types.setTypeParser(1182, parseArray)
Example #9
Source File: db.ts    From postgres-meta with Apache License 2.0 5 votes vote down vote up
// _date
types.setTypeParser(1185, parseArray)
Example #10
Source File: db.ts    From postgres-meta with Apache License 2.0 5 votes vote down vote up
// _timestamptz
types.setTypeParser(600, (x) => x)
Example #11
Source File: db.ts    From postgres-meta with Apache License 2.0 5 votes vote down vote up
// point
types.setTypeParser(1017, (x) => x)