app.get('/delete/:id', function(request, response) { people.remove({ _id: new mongo.ObjectID(request.params.id) }, function(err) { if(err) throw err; response.redirect("/");
/* * Delete a contact app.del("/contacts/:id", function (req, res) { console.log("Deleting contact id", req.params.id); db.collection("people").remove({"_id" : new ObjectID(req.params.id)}, function (err, removed) { if (err) { throw err; } else { console.dir("Successfully removed " + removed + " documents!"); res.send("Contact deleted", 200);
/** * ドキュメントを削除します * @param {string} collectionName * @param {Object} query * @param {Object} options * @return {Promise<void>} async remove(collectionName, query, options) { if (collectionName == null || query == null) { throw new MissingArgumentsError(); await this._db.collection(collectionName).remove(query, options);
/** * @description 删除 * @param {Object} options * @returns promise remove(options) { let self = this; return new Promise((resolve, reject) => { try { options = Object.assign({ justOne: false }, options); self.db.collection(options.table).remove(options.terms, (err, docs) => { err ? reject({ ok: -1, es: err }) : resolve(docs.result, docs); } catch (e) { reject({ ok: -1, es: e
db.collection('basicInfo', function(err, tb1){ tb1.remove({'id': req.params.id}, function(err, res1){ if(!err){ db.collection('profInfo', function(err, tb2){ tb2.remove({'id': req.params.id}, function(err, res2){ if(!err){ db.collection('otherInfo', function(err, tb3){ tb3.remove({'id': req.params.id}, function(err, res3){ if(!err){ res.send('All tables flushed using given ID' + res); else{ res.send('ID not found in otherInfo table '+ err); else{ res.send('ID not found in profInfo table '+ err); else{ res.send('ID not found in basicInfo table '+ err);
/** * Reset the database. This deletes all data and loads the sample/test data app.post("/flintstones", function (req, res) { db.collection("people").remove(function (err, removed) { if (err) { throw err; } else { // console.dir("Successfully removed " + removed + " documents!"); db.collection("people").insert(testData, function (err, result) { // insert takes an object or array of objects if (err) { throw err; } else { // console.dir("Successfully inserted: " + JSON.stringify(result.length) + " documents"); // Note the returned value (result) is an array even if it’s one document res.send(result);