tachybase_todo/packages/plugin-pages/src/actions/getPageInfo.ts

15 lines
438 B
TypeScript
Raw Normal View History

import { ResourceOptions } from '@nocobase/resourcer';
import { Model, ModelCtor } from '@nocobase/database';
import { get } from 'lodash';
export default async (ctx, next) => {
const { resourceName, resourceKey } = ctx.action.params;
const M = ctx.db.getModel(resourceName) as ModelCtor<Model>;
const model = await M.findByPk(resourceKey);
ctx.body = {
pageTitle: model.title,
...model.toJSON(),
};
await next();
};