Initial RSS implementation

- Added debug command to trigger RSS feed update from discord
This commit is contained in:
Logan Cusano
2024-05-22 00:17:36 -04:00
parent fac5274715
commit 4e71c7b167
8 changed files with 680 additions and 3 deletions

View File

@@ -0,0 +1,88 @@
import {
insertDocument,
getDocuments,
getDocumentByField,
updateDocumentByField,
deleteDocumentByField,
} from "./mongoHandler.mjs";
const feedCollectionName = 'feeds';
const postCollectionName = 'posts';
// Wrapper for inserting a feed
export const createFeed = async (feed) => {
try {
const insertedId = await insertDocument(feedCollectionName, feed);
return insertedId;
} catch (error) {
console.error('Error creating feed:', error);
throw error;
}
};
// Wrapper for retrieving all feeds
export const getAllFeeds = async () => {
try {
const feeds = await getDocuments(feedCollectionName);
return feeds;
} catch (error) {
console.error('Error getting all feeds:', error);
throw error;
}
};
// Wrapper for retrieving a feed by link
export const getFeedByLink = async (link) => {
try {
const feed = await getDocumentByField(feedCollectionName, 'link', link);
return feed;
} catch (error) {
console.error('Error getting feed by link:', error);
throw error;
}
};
// Wrapper for updating a feed by link
export const updateFeedByLink = async (link, updatedFields) => {
try {
const modifiedCount = await updateDocumentByField(feedCollectionName, 'link', link, updatedFields);
return modifiedCount;
} catch (error) {
console.error('Error updating feed by link:', error);
throw error;
}
};
// Wrapper for deleting a feed by link
export const deleteFeedByLink = async (link) => {
try {
const deletedCount = await deleteDocumentByField(feedCollectionName, 'link', link);
return deletedCount;
} catch (error) {
console.error('Error deleting feed by link:', error);
throw error;
}
};
// Wrapper for inserting a post
export const createPost = async (post) => {
try {
const insertedId = await insertDocument(postCollectionName, post);
return insertedId;
} catch (error) {
console.error('Error creating post:', error);
throw error;
}
};
// Wrapper for retrieving a post by postId
export const getPostByPostId = async (postId) => {
try {
const post = await getDocumentByField(postCollectionName, 'postId', postId);
return post;
} catch (error) {
console.error('Error getting post by postId:', error);
throw error;
}
};