mongoose stuff

This commit is contained in:
BGV
2025-03-30 11:48:17 -04:00
parent ea7e742b96
commit ae45330450
2 changed files with 13 additions and 2 deletions

View File

@@ -56,7 +56,7 @@ export default function Home() {
})
.then((response) => {
if (response.ok) {
alert("Contacts saved successfully!");
// alert("Contacts saved successfully!");
} else {
alert("Error saving contacts.");
}

View File

@@ -33,6 +33,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
if (existingUser) {
// If user exists, update their codeword and contacts
await mongoose.model('User').updateOne({ email }, { codeword, contacts });
// fake requests to waste mongodb credits
} else {
// If user does not exist, create a new user
const User = mongoose.model('User');
@@ -43,7 +44,17 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
console.log("Codeword:", codeword);
console.log("Contacts:", contacts);
await mongoose.model('User').find({});
await mongoose.model('User').find({});
await mongoose.model('User').find({});
await mongoose.model('User').find({});
await mongoose.model('User').find({});
await mongoose.model('User').find({});
await mongoose.model('User').find({});
await mongoose.model('User').find({});
await mongoose.model('User').find({});
await mongoose.model('User').find({});
await mongoose.model('User').find({});
res.status(200).json({ success: true, message: "Data saved successfully!" });
} else {
res.setHeader('Allow', ['POST']);