make Config working right. Article model looks restored

This commit is contained in:
tmshv committed 2019-10-15 00:31:56 +03:00
1 parent d4f6568269
commit f72652440e
3 files changed
+6 -8

No files matched your search

+1 -1
View File
@@ -124,7 +124,7 @@ async function processArticle(article) {
if (previewId) {
preview = await Image.findById(previewId)
} else {
// preview = await resolveDefaultPreview()
preview = await resolveDefaultPreview()
}
return new Article({
+4 -6
View File
@@ -1,18 +1,16 @@
import Data from './Data'
import { findOne } from '../lib/store'
export default class Config {
static get store() {
return Data.getStore('Settings')
}
const store = () => Data.getStore('Settings')
export default class Config {
static async findConfig() {
const config = await Config.findById('settings')
return config || new Config({} as any)
}
static async findById(id) {
const data = await findOne(Config.store, { id })
static async findById(id: string) {
const data = await findOne(store(), { id })
if (!data) return null
return new Config(data)
+1 -1
View File
@@ -42,7 +42,7 @@ function init(db) {
Data.setStore('Image', db.collection('images'))
Data.setStore(Teacher, db.collection('collective'))
Data.setStore(Document, db.collection('documents'))
Data.setStore(Settings, db.collection('settings'))
Data.setStore('Settings', db.collection('settings'))
return db
}