12345678910111213141516171819202122232425 |
- import Dict, { DictCreationAttributes } from '../models/dict';
- export async function getDict(key: string) {
- const res = await Dict.findOne({
- where: { key },
- }).catch((err) => {
- console.dir(err);
- });
- return res ? res.dataValues.val : '';
- }
- export async function updateDict(data: DictCreationAttributes) {
- const dict = await Dict.findOne({
- where: { key: data.key },
- });
- if (dict) {
- dict.val = data.val;
- await dict.save();
- return dict;
- }
- const res = await Dict.create(data);
- return res.dataValues;
- }
|