refactor: migrate to objection.js + knex

This commit is contained in:
NGPixel
2018-05-19 16:40:07 -04:00
parent e03e6826a8
commit c9b643fbf0
46 changed files with 1260 additions and 959 deletions

View File

@@ -38,7 +38,8 @@ module.exports = async (job) => {
const locales = await WIKI.redis.get('locales')
if (locales) {
const currentLocale = _.find(JSON.parse(locales), ['code', job.data.locale]) || {}
await WIKI.db.Locale.upsert({
await WIKI.db.locales.query().delete().where('code', job.data.locale)
await WIKI.db.locales.query().insert({
code: job.data.locale,
strings: lcObj,
isRTL: currentLocale.isRTL,

View File

@@ -60,13 +60,13 @@ module.exports = async (job) => {
_.set(lcObj, row.key.replace(':', '.'), row.value)
})
await WIKI.db.Locale.upsert({
await WIKI.db.locales.query().update({
code: WIKI.config.site.lang,
strings: lcObj,
isRTL: currentLocale.isRTL,
name: currentLocale.name,
nativeName: currentLocale.nativeName
})
}).where('code', WIKI.config.site.lang)
}
WIKI.logger.info('Syncing locales with Graph endpoint: [ COMPLETED ]')