16 lines
612 B
JavaScript
16 lines
612 B
JavaScript
import { pool } from '../pool.js';
|
|
|
|
export async function seen(source, source_id, entity_type) {
|
|
const { rows: [r] } = await pool.query(
|
|
`SELECT entity_id FROM migration_map WHERE source=$1 AND source_id=$2 AND entity_type=$3`,
|
|
[source, source_id, entity_type]);
|
|
return r ? r.entity_id : null;
|
|
}
|
|
|
|
export async function record(source, source_id, entity_type, entity_id) {
|
|
await pool.query(
|
|
`INSERT INTO migration_map(source, source_id, entity_type, entity_id) VALUES($1,$2,$3,$4)
|
|
ON CONFLICT (source, source_id, entity_type) DO NOTHING`,
|
|
[source, source_id, entity_type, entity_id]);
|
|
}
|