From 12e4d27b19b6bd381731d689ecb17d69af724d02 Mon Sep 17 00:00:00 2001 From: leomet07 Date: Fri, 26 Jan 2024 15:58:29 -0500 Subject: [PATCH] Match types in db --- db.ts | 8 ++++---- ts_types/db_types.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/db.ts b/db.ts index 8d8d442..0a92921 100644 --- a/db.ts +++ b/db.ts @@ -19,7 +19,7 @@ async function applyTextImageCredit( .aggregate([ { $match: { - article_id: new ObjectId(String(v._id)), + article: new ObjectId(String(v._id)), }, }, { @@ -45,7 +45,7 @@ async function applyTextImageCredit( ); if (!current_extra) { - throw new Error("No current extra found matchign that index!"); + throw new Error("No current extra found matching index " + img_index + " !"); } const current_contributor = current_extra.contributors[0]; @@ -318,7 +318,7 @@ async function get_media_by_author(author_id: mongoObjectId, num?: number) { let extras_collection = await db.collection("article_extras"); - interface ExtraWithArticle extends ReceivedArticleExtra { + type ExtraWithArticle = Omit & { article: ReceivedArticle[]; } @@ -333,7 +333,7 @@ async function get_media_by_author(author_id: mongoObjectId, num?: number) { { $lookup: { from: "articles", - localField: "article_id", + localField: "article", foreignField: "_id", as: "article", }, diff --git a/ts_types/db_types.ts b/ts_types/db_types.ts index db0308a..c92c164 100644 --- a/ts_types/db_types.ts +++ b/ts_types/db_types.ts @@ -34,7 +34,7 @@ export interface ReceivedStaff { export interface ReceivedArticleExtra { _id: mongoObjectId; - article_id: mongoObjectId; + article: mongoObjectId; contributors: ReceivedStaff[]; type: string; index: number;