first commit

This commit is contained in:
2024-05-16 16:05:41 +02:00
commit adf8283ae0
197 changed files with 26666 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
const connectDb = require("./db");
const save = async (newDocument) => {
const db = await connectDb();
if (!db) {
throw new Error('Database not connected');
}
const collection = db.collection("Favorites");
let result = await collection.insertOne(newDocument);
return result;
};
const getAll = async () => {
const db = await connectDb();
if (!db) {
throw new Error('Database not connected');
}
const collection = db.collection("Favorites");
let result = await collection.find({}).toArray();
return result;
};
module.exports = { save, getAll };