@@ -14,9 +14,9 @@ const fileSchema = new Schema(
1414 url : { type : String } ,
1515 children : { type : [ String ] , default : [ ] } ,
1616 fileType : { type : String , default : 'file' } ,
17- isSelectedFile : { type : Boolean }
17+ isSelectedFile : { type : Boolean , default : false }
1818 } ,
19- { timestamps : true , _id : true , usePushEach : true }
19+ { timestamps : true }
2020) ;
2121
2222fileSchema . virtual ( 'id' ) . get ( function getFileId ( ) {
@@ -36,11 +36,11 @@ const projectSchema = new Schema(
3636 } ,
3737 user : { type : Schema . Types . ObjectId , ref : 'User' } ,
3838 serveSecure : { type : Boolean , default : false } ,
39- files : { type : [ fileSchema ] } ,
39+ files : { type : [ fileSchema ] , default : [ ] } ,
4040 _id : { type : String , default : shortid . generate } ,
4141 slug : { type : String }
4242 } ,
43- { timestamps : true , usePushEach : true }
43+ { timestamps : true }
4444) ;
4545
4646projectSchema . virtual ( 'id' ) . get ( function getProjectId ( ) {
@@ -52,13 +52,10 @@ projectSchema.set('toJSON', {
5252} ) ;
5353
5454projectSchema . pre ( 'save' , function generateSlug ( next ) {
55- const project = this ;
56-
57- if ( ! project . slug ) {
58- project . slug = slugify ( project . name , '_' ) ;
55+ if ( ! this . slug ) {
56+ this . slug = slugify ( this . name , { lower : true , strict : true } ) ;
5957 }
60-
61- return next ( ) ;
58+ next ( ) ;
6259} ) ;
6360
6461/**
0 commit comments