Skip to content

Commit

Permalink
fix: pg bigint
Browse files Browse the repository at this point in the history
  • Loading branch information
fengkx committed Apr 10, 2022
1 parent 86a74b3 commit 9c115ec
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions source/knexfile.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
/* eslint @typescript-eslint/explicit-module-boundary-types: 0 */
try {
const pg = require('pg');
pg.types.setTypeParser(20, 'text', parseInt);
} catch (err) {
logger.info('There is no pg');
}
import { config } from './config';
import { parse } from 'url';
import { Knex } from 'knex';
Expand Down
6 changes: 5 additions & 1 deletion source/proxies/rss-feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export async function sub(
}
} else {
await db.transaction(async (trx) => {
const [feed_id] = await db('rss_feed')
let [feed_id] = await db('rss_feed')
.insert(
{
url: feedUrl,
Expand All @@ -41,7 +41,11 @@ export async function sub(
},
'feed_id'
)
.returning('feed_id')
.transacting(trx);
if (typeof feed_id === 'object') {
feed_id = feed_id.feed_id; // pg return object
}
await db('subscribes')
.insert({ feed_id, user_id: userId }, 'subscribe_id')
.transacting(trx);
Expand Down

0 comments on commit 9c115ec

Please sign in to comment.