Skip to content

Commit

Permalink
Match types in db
Browse files Browse the repository at this point in the history
  • Loading branch information
leomet07 committed Jan 26, 2024
1 parent d6c38cd commit 12e4d27
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async function applyTextImageCredit(
.aggregate<ReceivedArticleExtra>([
{
$match: {
article_id: new ObjectId(String(v._id)),
article: new ObjectId(String(v._id)),
},
},
{
Expand All @@ -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];
Expand Down Expand Up @@ -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<ReceivedArticleExtra, 'article'> & {
article: ReceivedArticle[];
}

Expand All @@ -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",
},
Expand Down
2 changes: 1 addition & 1 deletion ts_types/db_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export interface ReceivedStaff {

export interface ReceivedArticleExtra {
_id: mongoObjectId;
article_id: mongoObjectId;
article: mongoObjectId;
contributors: ReceivedStaff[];
type: string;
index: number;
Expand Down

0 comments on commit 12e4d27

Please sign in to comment.