问题描述:

Folks, for some reason this method is not letting me delete a user by email.

I have tested the functions calling this method, and they are in fact being executed.... thoughts?

var deleteUser = function (emailAddress, callback) {

Users.find({ email:emailAddress }).remove( callback );

}

all of code:

var Users = require('./mongo/users').Users;

var deleteUser = function (emailAddress, callback) {

Users.find({ email:emailAddress }).remove( callback );

}

./mongo/users.js:

var mongoose = require('mongoose');

var Schema = require('mongoose').Schema;

var UserSchema = new Schema({

email: {

type: String,

index: true

},

token: {

type: String,

index: true

},

password: String,

uid: {

type: String,

index: true

},

firstName: String,

lastName: String,

roles: Array

});

UserSchema.statics.findByEmail = function (email, callback) {

this.find({

email: new RegExp(email, 'i')

},

callback)

}

var Users = mongoose.model('users', UserSchema);

module.exports = {

Users: Users

}

相关阅读:
Top