How to stop inserting duplicate records before saving in db?
<p>I'm trying to save students records, but it should not take duplicate records. How is it possible? In below code i have tried to do</p>

<pre><code>app.post("/save",function(req,res){

    var std=new student(req.body);
    student.findOne({},function(err,success){
        if(err)
        {
            console.log(err);
        }
        else
        {
            // console.log(success);
            std.save(function(err,success){
            if(err)
                {
                    console.log(err);
                }
            else
                {
                    console.log("inserted");
                    console.log(success);
                }
            });

        }
    })
});
</code></pre>