政务数据资源中心(Government data Resource center) 03专项3期主要建设内容
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

39 lines
1.0 KiB

'use strict';
function searchMeta(opts) {
return async function (ctx, next) {
let errMsg = { message: '搜索元数据失败' }
try {
const models = ctx.fs.dc.models;
const { keywords } = ctx.query;
const where = {};
if (keywords) {
where['$or'] = [{ name: { $iLike: `%${keywords}%` } }
]
}
const findObj = {
include: [
{
model: models.TagDatabase,
include: [{
model: models.Tag,
}]
}],
where: where
}
const rslt = await models.MetadataDatabase.findAndCountAll(findObj);
ctx.status = 200;
ctx.body = rslt;
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = errMsg
}
}
}
module.exports = {
searchMeta
}