I want to make the key project unique across that collection but i cant getting this working, i found similar problem here.
task.js
function make(Schema,
The Schema object you're passing may not work correctly because you are nesting 'unique' attribute into 'index' attribute, try something like this (it works as intended) :
User = mongoose.model('User', new Schema({
firstName: {
type:String,
required: true,
},
lastName: {
type:String,
required: true,
},
email: {
type:String,
required: true,
unique: true
},
address: String,
phone: {
type:String,
required: true,
},
password: {
type:String,
required: true,
set: Data.prototype.saltySha1 // some function called before saving the data
},
role: String
},{strict: true}));
Or more specifically for your example :
var Tasks = new Schema({
project: {
type: String,
unique: true,
index: true
},
description: String
});
Note : I don't know what you're trying to do with the "dropDups" parameter, it doesn't seems to be in the mongoose documentation.