Skip to content

Commit

Permalink
refactor(config): Use queryObject for better data structuring in KV l…
Browse files Browse the repository at this point in the history
…istener
  • Loading branch information
csulit committed Oct 24, 2024
1 parent 529da98 commit c3a7c87
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions config/deno-kv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ export async function listenQueue(kv: Deno.Kv) {
let property;

try {
property = await transaction.queryArray({
property = await transaction.queryObject({
args: [
dataLayerAttributes?.floor_size || 0,
dataLayerAttributes?.land_size || 0,
Expand Down Expand Up @@ -357,7 +357,7 @@ export async function listenQueue(kv: Deno.Kv) {
throw error;
}

const newProperty = property.rows[0][0] as number;
const newProperty = property.rows[0] as { id: number };

const address = `${
dataLayerAttributes?.listing_area
Expand All @@ -366,7 +366,7 @@ export async function listenQueue(kv: Deno.Kv) {
}${dataLayerAttributes.listing_city}`;

try {
await transaction.queryArray({
await transaction.queryObject({
args: [
msg.data.dataLayer?.title,
`https://www.lamudi.com.ph/${dataLayerAttributes?.urlkey_details}`,
Expand All @@ -381,7 +381,7 @@ export async function listenQueue(kv: Deno.Kv) {
: null,
dataLayerAttributes?.price || 0,
offerTypeId,
newProperty,
newProperty.id,
],
text: `INSERT INTO Listing (title, url, project_name, description, is_scraped, address, price_formatted, price, offer_type_id, property_id)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) RETURNING id`,
Expand Down

0 comments on commit c3a7c87

Please sign in to comment.