Solved! Mongoose Unique Index Not Working - DEV Community ๐ฉโ๐ป๐จโ๐ป
Thu Jul 22 2021 05:42:32 GMT+0000 (Coordinated Universal Time)
Saved by
@jaimin
'use strict'
import 'dotenv/config'
import db from 'mongoose'
const options = {
useNewUrlParser: true,
useCreateIndex: true,
autoIndex: true, //this is the code I added that solved it all
keepAlive: true,
poolSize: 10,
bufferMaxEntries: 0,
connectTimeoutMS: 10000,
socketTimeoutMS: 45000,
family: 4, // Use IPv4, skip trying IPv6
useFindAndModify: false,
useUnifiedTopology: true
}
db.connect(process.env.DB_URI, options)
.then(() => console.log('> Successfully connected to DB'))
.catch(err => console.log(err))
// syntactic sugar for { db: db }
export default { db }
content_copyCOPY
Email unique validation not working
https://dev.to/emmysteven/solved-mongoose-unique-index-not-working-45d5
Comments