请问如何通过Tag模糊查询获取所有包含该标签的文章列表
zhangsanplus opened this issue · 4 comments
zhangsanplus commented
例如: 用户按标签查询,输入关键字 Javascript
获取如下结果
[
{
createdAt: "2020-01-14 15:51:24",
updatedAt: "2020-04-13 14:35:55",
id: 87,
title: " React Hooks 笔记",
content: "content值",
viewCount: 66,
tags: [{name: "Javascript", name: "react"}],
categories: [{name: "Javascript"}],
comments: []
},
{
createdAt: "2020-01-14 15:51:24",
updatedAt: "2020-04-13 14:35:55",
id: 88,
title: " React Hooks 笔记1",
content: "content值",
viewCount: 66,
tags: [{name: "Javascript", name: "vue"}],
categories: [{name: "Javascript"}],
comments: []
}
]
const { tag_name } = ctx.query
.....
const data = await ArticleModel.findAndCountAll({
这个查询sql 该怎么写
})
alvin0216 commented
使用 $like
进行模糊查询
zhangsanplus commented
有具体的代码吗? 就你的这个项目而言
alvin0216 commented
zhangsanplus commented