猫鼬没有移除物体

时间:2014-06-13 01:17:49

标签: javascript node.js mongodb mongoose

由于某种原因,这个方法不允许我按email删除用户。

我已经测试了调用此方法的函数,它们实际上正在执行....想法?

var deleteUser = function (emailAddress, callback) {
    Users.find({ email:emailAddress }).remove( callback );
}

所有代码:

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

var deleteUser = function (emailAddress, callback) {
    Users.find({ email:emailAddress }).remove( callback );
}

./蒙戈/ 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
}

0 个答案:

没有答案