Skip to content

Commit 9c115ec

Browse files
committed
fix: pg bigint
1 parent 86a74b3 commit 9c115ec

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

source/knexfile.ts

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
/* eslint @typescript-eslint/explicit-module-boundary-types: 0 */
2+
try {
3+
const pg = require('pg');
4+
pg.types.setTypeParser(20, 'text', parseInt);
5+
} catch (err) {
6+
logger.info('There is no pg');
7+
}
28
import { config } from './config';
39
import { parse } from 'url';
410
import { Knex } from 'knex';

source/proxies/rss-feed.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export async function sub(
3232
}
3333
} else {
3434
await db.transaction(async (trx) => {
35-
const [feed_id] = await db('rss_feed')
35+
let [feed_id] = await db('rss_feed')
3636
.insert(
3737
{
3838
url: feedUrl,
@@ -41,7 +41,11 @@ export async function sub(
4141
},
4242
'feed_id'
4343
)
44+
.returning('feed_id')
4445
.transacting(trx);
46+
if (typeof feed_id === 'object') {
47+
feed_id = feed_id.feed_id; // pg return object
48+
}
4549
await db('subscribes')
4650
.insert({ feed_id, user_id: userId }, 'subscribe_id')
4751
.transacting(trx);

0 commit comments

Comments
 (0)