I have a collection called customers and it contains documents. I have written a function to delete a document using the field and its value which takes as arguments. But it doe
Rewrite your function so that the arguments become part of the query object. You can do this using either computed property or bracket notation.
Using computed property:
function removeDocument(fieldName, value) {
db.customers.remove({[fieldName]: value});
}
Using bracket notation
function removeDocument(fieldName, value) {
var query = {};
query[fieldName] = value;
db.customers.remove(query);
}