@@ -55,45 +55,42 @@ jobs.createSearchTags = function(data, done){
55
55
56
56
var ourDoc = data ;
57
57
var split = [ ] ;
58
- if ( ourDoc && ourDoc . _id ) {
59
- delete ourDoc . _id ;
60
- }
61
-
62
- if ( ourDoc && ourDoc . createdAt ) {
63
- delete ourDoc . createdAt ;
64
- }
65
-
66
- if ( ourDoc && ourDoc . updatedAt ) {
67
- delete ourDoc . updatedAt ;
68
- }
69
-
70
- if ( ourDoc && ourDoc . tags ) {
71
- delete ourDoc . tags ;
72
- }
73
58
74
59
for ( var n in ourDoc ) {
75
- if ( typeof ourDoc [ n ] === 'string' ) {
76
- split . push ( ourDoc [ n ] . split ( ' ' ) ) ;
60
+ if ( ourDoc [ n ] === ourDoc . _id ) { /* jslint ignore:line */
61
+ // Skip
62
+ } else if ( ourDoc [ n ] === ourDoc . createdAt ) { /* jslint ignore:line */
63
+ // Skip
64
+ } else if ( ourDoc [ n ] === ourDoc . updatedAt ) { /* jslint ignore:line */
65
+ // Skip
66
+ } else if ( ourDoc [ n ] === ourDoc . tags ) { /* jslint ignore:line */
67
+ // Skip
68
+ } else {
69
+ if ( typeof ourDoc [ n ] === 'string' ) {
70
+ split . push ( ourDoc [ n ] . split ( ' ' ) ) ;
71
+ } else { /* jslint ignore:line */
72
+ // Move on nothing to see here
77
73
}
78
74
}
79
75
80
- split = _ . flattenDeep ( split ) ;
81
-
82
- var task ;
83
- if ( update ) {
84
- task = models [ model ] . update ( data , { $set : { updatedAt : new Date ( ) . toISOString ( ) } , $addToSet : { tags : { $each : split } } } ) ;
85
- } else {
86
- task = models [ model ] . update ( data , { $set : { tags : split } } ) ;
87
- }
88
-
89
- task
90
- . then ( function ( res ) {
91
- return done ( false , res ) ;
92
- } )
93
- . catch ( function ( err ) {
94
- log . error ( err ) ;
95
- return done ( new Error ( err . message ) ) ;
96
- } ) ;
76
+ }
77
+ split = _ . flattenDeep ( split ) ;
78
+
79
+ var task ;
80
+ if ( update ) {
81
+ task = models [ model ] . update ( data , { $set : { updatedAt : new Date ( ) . toISOString ( ) } , $addToSet : { tags : { $each : split } } } ) ;
82
+ } else {
83
+ task = models [ model ] . update ( data , { $set : { tags : split } } ) ;
84
+ }
85
+
86
+ task
87
+ . then ( function ( res ) {
88
+ return done ( false , res ) ;
89
+ } )
90
+ . catch ( function ( err ) {
91
+ log . error ( err ) ;
92
+ return done ( new Error ( err . message ) ) ;
93
+ } ) ;
97
94
} ;
98
95
99
96
// Backup Data to Trash
0 commit comments