enzostvs's picture
enzostvs HF Staff
Upload 172 files
9cd6ddb verified
raw
history blame contribute delete
629 Bytes
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import type { NextApiRequest, NextApiResponse } from "next";
import { API } from "utils/api";
import clientPromise from "lib/mongo";
export default async function handler(
req: NextApiRequest,
res: NextApiResponse
) {
const client = await clientPromise;
const db = client.db("test");
const getCount = await db.collection("icons").findOne({
counter: true,
});
await db.collection("icons").updateOne(
{
counter: true,
},
{
$set: {
amount: getCount.amount + 1,
},
}
);
res.status(200);
}