skip to Main Content

Mongodb – Delete nested object with Mongoose and Next js

My route is below: export async function GET() { await connectMongoDB(); const allCargoDetails = await CargoDetails.find(); return NextResponse.json({ allCargoDetails }); } export async function DELETE(request) { const id = request.nextUrl.searchParams.get("id"); await connectMongoDB(); await CargoDetails.findByIdAndDelete(id); return NextResponse.json({ message: "Detaily smazány" });…

VIEW QUESTION

Mongodb – Node mongo group by specific field

I have a response like this: "data": [ { "_id": "6664a8f2f233916895656171", "workout_plan_id": "6664a5a089450f21a8dd69dc", "day": "Monday", "exercise_id": "66643259d020507ed008b16d", "reps": 15, "sets": 3, "created_on": "2024-06-08T18:54:16.287Z", "updated_on": "2024-06-08T18:54:16.287Z", "__v": 0 }, { "_id": "6664aa55ce325f608597f5e8", "workout_plan_id": "6664a5a089450f21a8dd69dc", "day": "Monday", "exercise_id": "66643259d020507ed008b16d", "reps": 15, "sets":…

VIEW QUESTION
Back To Top
Search