skip to Main Content

Mongodb – how to mongoose delete cascade in latest version of mongoose without model.remove()?

Not able to delete cascade as Model.remove() fuction is not available in mongoose. using findByIdAndDelete is not invoking the middleware: BootcampSchema.pre('remove',async function(next){ //before deleting the doc console.log(`courses being removed from bootcamp ${this._id}`); await this.model('Course').deleteMany({bootcamp:this._id}); next(); }); tried different delete methods…

VIEW QUESTION

Can't load generated public key from NodeJS into Windows via CNG APIs – Javascript

I generate RSA public/private key pairs in NodeJS using crypto library: crypto.generateKeyPair( "rsa", { modulusLength: 1024, publicKeyEncoding: { type: "pkcs1", format: "pem", }, privateKeyEncoding: { type: "pkcs1", format: "pem", }, }, (err, publicKey, privateKey) => { fs.writeFileSync("/home/dev/priv.pem", privateKey); fs.writeFileSync("/home/dev/pub.pem", publicKey);…

VIEW QUESTION
Back To Top
Search