-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trendiness Update and Migration Script for New Flyers Model (#106)
* Add migration script to update data based on new Flyers schema * Update Flyer trendiness * Fix comments * Clean up syntax for get trending flyers * Remove unnecessary createSpecificsByIndex function
- Loading branch information
1 parent
b0976c5
commit d43a4f5
Showing
7 changed files
with
89 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
module.exports = { | ||
up(db) { | ||
/** | ||
* Updating flyers model to switch to singular organization object and | ||
* singular organization slug | ||
*/ | ||
return db.collection('flyers').updateMany({}, [ | ||
{ | ||
$set: { | ||
organization: { $first: '$organizations' }, | ||
organizationSlug: { $first: '$organizationSlugs' }, | ||
}, | ||
}, | ||
{ | ||
$unset: ['organizations', 'organizationSlugs'], | ||
}, | ||
]); | ||
}, | ||
|
||
down(db) { | ||
/** | ||
* Reset organizations field to array of size 1 containing current flyer's | ||
* organization. Resets organizationSlugs to an array of size 1 containing | ||
* current flyer's organization slug. | ||
*/ | ||
return db.collection('flyers').updateMany({}, [ | ||
{ | ||
$set: { | ||
organizations: ['$organization'], | ||
organizationSlugs: ['$organizationSlug'], | ||
}, | ||
}, | ||
{ | ||
$unset: ['organization', 'organizationSlug'], | ||
}, | ||
]); | ||
}, | ||
}; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters