-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: trim white space throughout word documents
- Loading branch information
Showing
3 changed files
with
125 additions
and
20 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
103 changes: 103 additions & 0 deletions
103
migrations/20230605005447-trim-headword-and-tenses-whitespace.js
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,103 @@ | ||
const trimPipeline = [ | ||
{ | ||
$project: { | ||
word: { | ||
$trim: { | ||
input: '$word', | ||
}, | ||
}, | ||
wordPronunciation: 1, | ||
conceptualWord: 1, | ||
definitions: 1, | ||
dialects: 1, | ||
tags: 1, | ||
'tenses.infinitive': { | ||
$trim: { | ||
input: '$tenses.infinitive', | ||
}, | ||
}, | ||
'tenses.imperative': { | ||
$trim: { | ||
input: '$tenses.imperative', | ||
}, | ||
}, | ||
'tenses.simplePast': { | ||
$trim: { | ||
input: '$tenses.simplePast', | ||
}, | ||
}, | ||
'tenses.presentPassive': { | ||
$trim: { | ||
input: '$tenses.presentPassive', | ||
}, | ||
}, | ||
'tenses.simplePresent': { | ||
$trim: { | ||
input: '$tenses.simplePresent', | ||
}, | ||
}, | ||
'tenses.presentContinuous': { | ||
$trim: { | ||
input: '$tenses.presentContinuous', | ||
}, | ||
}, | ||
'tenses.future': { | ||
$trim: { | ||
input: '$tenses.future', | ||
}, | ||
}, | ||
attributes: 1, | ||
pronunciation: 1, | ||
variations: 1, | ||
frequency: 1, | ||
relatedTerms: 1, | ||
hypernyms: 1, | ||
hyponyms: 1, | ||
stems: 1, | ||
__v: 1, | ||
updatedAt: 1, | ||
createdAt: 1, | ||
}, | ||
}, | ||
]; | ||
|
||
const revertTrimPipeline = [ | ||
{ | ||
$project: { | ||
word: 1, | ||
wordPronunciation: 1, | ||
conceptualWord: 1, | ||
definitions: 1, | ||
dialects: 1, | ||
tags: 1, | ||
tenses: 1, | ||
attributes: 1, | ||
pronunciation: 1, | ||
variations: 1, | ||
frequency: 1, | ||
relatedTerms: 1, | ||
hypernyms: 1, | ||
hyponyms: 1, | ||
stems: 1, | ||
__v: 1, | ||
updatedAt: 1, | ||
createdAt: 1, | ||
}, | ||
}, | ||
]; | ||
|
||
module.exports = { | ||
async up(db) { | ||
const collections = ['words', 'wordsuggestions']; | ||
await Promise.all(collections.map((collection) => ( | ||
db.collection(collection).updateMany({}, trimPipeline) | ||
))); | ||
}, | ||
|
||
async down(db) { | ||
const collections = ['words', 'wordsuggestions']; | ||
await Promise.all(collections.map((collection) => ( | ||
db.collection(collection).updateMany({}, revertTrimPipeline) | ||
))); | ||
}, | ||
}; |
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