Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问如何通过Tag模糊查询获取所有包含该标签的文章列表 #51

Open
zhangsanplus opened this issue Apr 15, 2020 · 4 comments

Comments

@zhangsanplus
Copy link

例如: 用户按标签查询,输入关键字 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
Copy link
Owner

使用 $like 进行模糊查询

@zhangsanplus
Copy link
Author

有具体的代码吗? 就你的这个项目而言

@alvin0216
Copy link
Owner

image

@zhangsanplus
Copy link
Author

image
我希望是 wd 来 搜索, 而不是新增tag 参数, 我这种写法不对,麻烦看看是什么原因

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants