I am working on Mongo and i need to maintain Unique value in field so i done filed as unique but if i submit the the error will be null .
Here is my code .
var RepositorySchema = new mongoose.Schema({
folderName: { type: String, unique: true},
tag: String ,
ismainFolder: { type: Boolean },
innerFiles: [{filename : String, isFolder: { type: Boolean }, parentfolderId: { type: Schema.ObjectId, ref: 'repository' }, filelocation: { type: String } }],
innerFolder: [{foldername: {type : String, unique: true}, ismainFolder: { type: Boolean }, parentfolderId: { type: Schema.ObjectId, ref: 'repository' } }],
});
For innerFolder {foldername: {type : String, unique: true} is not working .