Merge pull request #2821 from overleaf/jpa-ns-replace-spellcheck-languages

[script] add a script to replace all unsupported spell check languages

GitOrigin-RevId: 597033b7ae7733f8bc7e5e0f4dfb1a49d0cae3b4
This commit is contained in:
Jessica Lawshe 2020-05-12 09:47:32 -05:00 committed by Copybot
parent 295264697e
commit cbba4132e1

View file

@ -0,0 +1,50 @@
const { db } = require('../app/src/infrastructure/mongojs')
const languages = [
'am',
'hy',
'bn',
'gu',
'he',
'hi',
'hu',
'is',
'kn',
'ml',
'mr',
'or',
'ss',
'ta',
'te',
'uk',
'uz',
'zu',
'fi'
]
function main(callback) {
const query = { spellCheckLanguage: { $in: languages } }
db.projects.update(
query,
{ $set: { spellCheckLanguage: '' } },
{ multi: true },
(err, result) => {
if (err) {
return callback(err)
}
console.log(`>> Updated projects: ${JSON.stringify(result)}`)
return callback()
}
)
}
if (require.main === module) {
main(err => {
if (err) {
console.error(err)
return process.exit(1)
}
console.log('>> done')
process.exit(0)
})
}