models/student.js
//throws code:11000 if violated duplicate key error

throws code:11000 if violated duplicate key error
throws code : 11000 if violated duplicate key error
validate(value) {
            if (!/^[0-9]{4}$/.test(value)) {
                throw new Error('Invalid roll no')
            }
        }
validate ( value ) { if ( ! / ^[0-9]{4}$ / . test ( value ) ) { throw new Error ( 'Invalid roll no' ) } }
throws code:11000 if violated duplicate key error
throws code : 11000 if violated duplicate key error