aboutsummaryrefslogtreecommitdiff
path: root/pages/api/update-user.js
diff options
context:
space:
mode:
Diffstat (limited to 'pages/api/update-user.js')
-rw-r--r--pages/api/update-user.js31
1 files changed, 0 insertions, 31 deletions
diff --git a/pages/api/update-user.js b/pages/api/update-user.js
deleted file mode 100644
index 67c80d0..0000000
--- a/pages/api/update-user.js
+++ /dev/null
@@ -1,31 +0,0 @@
-// pages/api/update-user.js
-import clientPromise from "../../lib/mongodb";
-
-export default async function handler(req, res) {
- const client = await clientPromise;
- const db = client.db("authbase");
- const collection = db.collection("users");
-
- const { name, newData } = req.body; // id is the user ID and newData is the new data you want to set
-
- try {
- const existingData = await collection.findOne({
- name: name,
- "recentWatch.id": newData.recentWatch.id,
- });
-
- if (existingData) {
- res.status(200).json({ message: "Data already exists" });
- return;
- }
-
- const result = await collection.updateOne(
- { name: name },
- { $addToSet: newData }
- );
-
- res.status(200).json(result);
- } catch (error) {
- res.status(500).json({ error: "Unable to update user data" });
- }
-}