Skip to content

Commit 299003d

Browse files
committed
delete many used
1 parent 63f0c56 commit 299003d

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

app/api/[roomcode]/delete/route.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,9 @@ import clientPromise from '@/utils/newdb'
44
export async function DELETE(_request: Request, context: RoomCodeRouteContext) {
55
try {
66
const client = await clientPromise
7-
const db = client.db('get_interval')
7+
const db = client.db('get_interval');
88

9-
const rooms = await db
10-
.collection('rooms')
11-
.find({ roomcode: context.params.roomcode })
12-
.limit(10)
13-
.toArray()
14-
15-
for (let i = 0; i < rooms.length; i++) {
16-
db.collection('rooms').findOneAndDelete({ _id: rooms[i]._id })
17-
}
9+
db.collection('rooms').deleteMany({ roomcode: context.params.roomcode })
1810

1911
return new Response(JSON.stringify(''), { status: 200 })
2012
} catch (error) {

0 commit comments

Comments
 (0)