Questions tagged [mongoose-deleteone]
11 questions
5
votes
2 answers
Mongoose: deleteOne middleware for cascading delete not working
With remove being deprecated in Mongoose 5.7.13, I want to use deleteOne instead. I need to get the id of the deleted document so that I can then delete further related documents in other collections in a cascade. I thought that "this" within the…

notnot
- 4,472
- 12
- 46
- 57
1
vote
0 answers
mongoose - Delete all referenced objects when deleting referencing object
I have two collections in my app. (Table and Buckets)
Table collection
Bucket collection
Here each one site has many buckets. I want to delete all buckets and data using site id (site field in table collection)
If it's duplicated, feel free to…

Janaka Edirisinghe
- 537
- 6
- 15
0
votes
0 answers
findDeleted in mongoose-delete retrieves all elements with deleted field: true and false
I use mongoose-delete library in my project. After soft delete, soft deleted data will be in recycle bin (I use findDeleted to get soft deleted data)
const Course = require("../models/Course");
const { mutipleMongooseToObject } =…
0
votes
1 answer
Mongoose's Model.findByIdAndDelete() successfully deletes document but hangs afterwards
I am using express with mongoose and MongoDB. After creating a simple deletion route for my "Quiz" model, it deletes the document, however it never actually receives a response. I have tested with Postman and Insomnia.
Here is my controller:
const…

Toni Dinca
- 3
- 1
0
votes
1 answer
I'm working on my project and facing a problem in deleting a element in an array of objects
I'm working on my project and facing a problem in deleting a element in an array of objects ,the mongoose function run without error but the targated element won't delete at all .Help me with the code.
i want to delete the element of document(user)…

Rahul Bishnoi
- 1
- 1
0
votes
1 answer
Aggregation for deleteOne(...) function in MongoDB
I'm trying to delete a document with one operation, instead of two - countDocuments(...), deleteOne(...).
Condition: delete oldest document with user_id = xxx, if count of documents with user_id >= 5.
It's works, but it lacks document count check. I…

Jaroslav Kirichok
- 11
- 4
0
votes
0 answers
Not able to deleteOne() on MongoDB
Tryin to delete this document from my collection:
db.users.find({"dref._id": "USER_ONE", "dref.age" : 23, "school": "BRHS"})
When I search it using the find, i get it. I'm trying to use this for delete it:
db.users.deleteOne({"dref._id": "USER_ONE",…

Fragola 86
- 59
- 1
- 4
0
votes
0 answers
Delete document in mongodb collection with deleteOne where data is an object with the id
Im trying to delete a record in my mongodb collection that look like this
{
"name": "do sftp backup",
"data": {
"scheduleId": 95
},
"priority": 0,
"type": "normal",
"nextRunAt": null,
"lastModifiedBy": null,
…

Erraco
- 138
- 1
- 12
0
votes
1 answer
error while using deleteOne in app.delete function in Node.js
** trying to use the app.delete and trying to delete document from mondo db using delete one...it keep throwing errror. how to solve this error ? **
``` require('dotenv').config()
const express = require('express')
const app = express()
const PORT…
0
votes
1 answer
How to get an error by using deleteOne method of Mongoose with a key after deleting one document with the same key?
I have got stuck in a problem about deleteOne method of Mongoose.
The problem is as follows:
deleted a document by using deleteOne() with a key.
tried to delete the same document by using deleteOne() with the same key again, and then the method…

Takumasakix
- 23
- 8
0
votes
4 answers
MongoDb delete documents by passing user id
I am new to node and mongo db. I have a list of users with delete link in each row.I am trying to delete a user with its _id. However its not working.
Here is my router code.
router.get('/delete/:id', function (req,res) {
const ObjectId =…

Oops
- 1,373
- 3
- 16
- 46