@@ -7,7 +7,7 @@ import Analytics from '../../../../utils/analytics';
77export default {
88 createCategory ( category ) {
99 category . createdOn = new Date ( ) ;
10- category . createdBy = authManager . currentUser ;
10+ category . createdBy = authManager . sanitizedCurrentUser ;
1111 return Categories . create ( category . toJSON ( ) ) . then ( ( result ) => {
1212 Analytics . registerCategoryEvent ( result . id , result . title ) ;
1313 for ( const sub of result . subcategories ) {
@@ -45,38 +45,40 @@ export default {
4545 return Categories . search ( options ) ;
4646 } ,
4747 getAllCategories ( callback ) {
48- let searchOptions = {
49- limit : 50 ,
50- skip : 0 ,
51-
52- } , categories = [ ] ;
53-
48+ const options = {
49+ limit : 50 ,
50+ skip : 0 ,
51+ filter : { } ,
52+ sort : { title : 1 }
53+ } ;
54+ let categories = [ ] ;
55+
56+ options . filter [ "_buildfire.index.date1" ] = { $type : 10 } ;
57+
5458 const getCategoriesData = ( callback ) => {
55- Categories . search ( searchOptions ) . then ( result => {
56- if ( result . length < searchOptions . limit ) {
59+ Categories . search ( options ) . then ( ( result ) => {
60+ if ( result . length < options . limit ) {
5761 categories = categories . concat ( result ) ;
58- categories = categories . filter ( x => x . deletedBy == null ) ;
5962 return callback ( categories ) ;
6063 } else {
61- searchOptions . skip = searchOptions . skip + searchOptions . limit ;
64+ options . skip = options . skip + options . limit ;
6265 categories = categories . concat ( result ) ;
6366 return getCategoriesData ( callback ) ;
6467 }
6568 } )
6669 }
6770
6871 getCategoriesData ( callback ) ;
69-
7072 } ,
7173
7274 updateCategory ( categoryId , category ) {
7375 category . lastUpdatedOn = new Date ( ) ;
74- category . lastUpdatedBy = authManager . currentUser ;
76+ category . lastUpdatedBy = authManager . sanitizedCurrentUser ;
7577 return Categories . update ( categoryId , category . toJSON ( ) ) ;
7678 } ,
7779 deleteCategory ( categoryId , category ) {
7880 category . deletedOn = new Date ( ) ;
79- category . deletedBy = authManager . currentUser ;
81+ category . deletedBy = authManager . sanitizedCurrentUser ;
8082 return Categories . delete ( categoryId , category . toJSON ( ) ) ;
8183 }
8284} ;
0 commit comments