Mongoose: Remove Document and all references completely

108
January 11, 2019, at 12:30 PM

I was wondering. I have a lot of coding to do with a function to remove a document from the database. Basically removing just the object is not that much work, but removing the _id reference from all the other models step by step in the right order is the big work load (I pushed the object ID into the other objects so I could create relations and populate later).

I was wondering: is there no function standard in mongoose that instantly removes the document as well as all its objectId references in the documents of the other model types (so completely remove the object and all it's ObjectID references in all the other collections in the DB)?

Answer 1

You can achieve what you are looking for using this NPM package called cascading-relations here

READ ALSO
hyperledger fabric calling enrollment endpoint failed with error

hyperledger fabric calling enrollment endpoint failed with error

I was trying to deploy hyperledger fabric on multiple hosts using this code and used the balance transfer chaincode using node-SDKWhile I tried to enroll the user, I got the following error:

176
HTML Table to Excel Issue

HTML Table to Excel Issue

I'm using the TableExportjs API and PNP

24
How to create python application like pipenv or django-admin or pytest etc…?

How to create python application like pipenv or django-admin or pytest etc…?

I am writing a pip module that has to run from command lineI need some steps to create python application

58
Scrapy combine items from multiple processes

Scrapy combine items from multiple processes

I have a scrapy script that

132