以下はモデルの私のuserスキーマuser.jsです-
var userSchema = new mongoose.Schema({
    local: {
        name: { type: String },
        email : { type: String, require: true, unique: true },
        password: { type: String, require:true },
    },
    facebook: {
        id           : { type: String },
        token        : { type: String },
        email        : { type: String },
        name         : { type: String }
    }
});
var User = mongoose.model('User',userSchema);
module.exports = User;
これは私がコントローラーでそれを使用している方法です-
var user = require('./../models/user.js');
これは私がデータベースに保存する方法です-
user({'local.email' : req.body.email, 'local.password' : req.body.password}).save(function(err, result){
    if(err)
        res.send(err);
    else {
        console.log(result);
        req.session.user = result;
        res.send({"code":200,"message":"Record inserted successfully"});
    }
});
エラー -
{"name":"MongoError","code":11000,"err":"insertDocument :: caused by :: 11000 E11000 duplicate key error index: mydb.users.$email_1  dup key: { : null }"} 
私はdbコレクションをチェックしましたが、そのような重複するエントリは存在しません。何が間違っているのか教えてください。
FYI-   req.body.emailとreq.body.password値をフェッチしています。
私もこの投稿をチェックしましたが、助けはありませんSTACK LINK
完全に削除した場合、ドキュメントが挿入されます。それ以外の場合は、local.emailにエントリがあっても、エラー「重複」エラーがスローされます。
unique: falseに設定しても影響はありませんでした。最初にテーブルを削除する必要があり、それが機能することに気づきました。あなたはのような何かをすることができますdb.whateverthecollection.drop({})。注意してください、それはコレクションを削除します。
                