惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 三生石上(FineUI控件)
Martin Fowler
Martin Fowler
月光博客
月光博客
AI
AI
B
Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
C
CXSECURITY Database RSS Feed - CXSecurity.com
WordPress大学
WordPress大学
GbyAI
GbyAI
L
Lohrmann on Cybersecurity
O
OpenAI News
Schneier on Security
Schneier on Security
P
Palo Alto Networks Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
Troy Hunt's Blog
V2EX - 技术
V2EX - 技术
W
WeLiveSecurity
L
LINUX DO - 最新话题
人人都是产品经理
人人都是产品经理
S
Security Affairs
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
A
Arctic Wolf
Recorded Future
Recorded Future
Microsoft Security Blog
Microsoft Security Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
G
GRAHAM CLULEY
N
Netflix TechBlog - Medium
TaoSecurity Blog
TaoSecurity Blog
C
Check Point Blog
Scott Helme
Scott Helme
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Apple Machine Learning Research
Apple Machine Learning Research
PCI Perspectives
PCI Perspectives
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Vercel News
Vercel News
The Hacker News
The Hacker News
Y
Y Combinator Blog
Latest news
Latest news
SecWiki News
SecWiki News
Hugging Face - Blog
Hugging Face - Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Google Online Security Blog
Google Online Security Blog
Webroot Blog
Webroot Blog
Google DeepMind News
Google DeepMind News
Recent Commits to openclaw:main
Recent Commits to openclaw:main
C
Cisco Blogs
博客园_首页
H
Hackread – Cybersecurity News, Data Breaches, AI and More
宝玉的分享
宝玉的分享
L
LINUX DO - 热门话题

Mengke's blog - Mengke's coding journey

年轻不是健康的免死金牌 深圳工作机会,前端 2025 年终总结 Skill 不是 MCP 的替代品:我理解的渐进式披露与选型原则 独立开发者如何开具发票 香港银行卡开户完整指南(2025年9月最新) 招商银行储蓄卡微信动账提醒恢复方法 再谈 MCP - Model Context Protocol(MCP)详解和开发教程 Get Human-Readable "Time Ago" in TypeScript 以「asset-price-mcp」为例,从 0 开发 MCP Server Model Context Protocol (MCP) 快速开始 DeepSeek + Dify 搭建本地知识库 An elegant solution for implementing optional property types using TypeScript 2024 年终总结 Quickly Create a Fullscreen WebView with Autoplay Support for Testing 以数字开头的 ID 在 querySelector 中的处理 String casing utilities in JavaScript Check if a string is a valid color Simple Event-Emitter/PubSub pattern Find which process is running on a certain port and kill it Markdown Code block's basic and advanced syntaxes Common npm commands to use locally Pnpm aliases How to safely rename a case sensitive file/directory in a git repo? A custom hooks to use an async effect A custom hooks to use local storage state 🤩 Mengke'blog 上线的这一年 🗼 五月底去了一趟日本,记录一下我的游记和攻略 网站性能优化:如何高效预加载大型静态资源 闰年之约 - 2024年2月29日 A collection of some useful websites 2023 年终总结 WebGL 学习笔记(一)基础概念与实践 Android Webview <video> 标签去除默认播放按钮图 📷 纯前端也可以实现「用户无感知录屏」? Getting Spotify token to display now playing track on your website AVP - Web 端特效视频播放器 IndexedDB 基础入门 直接下载网易云音乐中歌曲MP3格式的方法 什么!一个项目给了8个字体包??? flex 布局中 start/end 和 flex-start/flex-end 的区别 深入 Pinia:从代码出发探索 Vue 状态管理的奥秘 Pinia 快速上手指南 Nest.js Typrorm 多对多关系如何创建 CentOS7 MySQL 数据库安装与卸载 Next.js 上手指南 Vue 数据响应式原理 deno 快速上手 - Hello World 案例 快速上手 Vue3 尝鲜 Vue 3.0 Combination API react-router-dom 路由基础教程 JavaScript 数组扁平化处理的方法总结
Strapi 快速入门
Mengke · 2023-04-11 · via Mengke's blog - Mengke's coding journey

Postman sign.webp

Published on
/

3 mins read

/

––– views

Share:

1. 安装

npx create-strapi-app@latest my-project
# or
yarn create strapi-app my-project --quickstart

2. 设置为中文

新建 src/app.js,并粘贴以下内容:

const config = {
    locales: ['zh'],
};
 
const bootstrap = (app) => {
    console.log(app);
};
 
export default {
    config,
    bootstrap,
};

重启后进入网站首页,点击左下角头像→个人资料→体验→界面语言,调整为中文即可。

Untitled

3. 新建表

默认已经创建了 User 表,点击 创建一个新的 Content Type 来创建表新表:

Untitled

4. 创建关系

在一个表中新建一个字段,类型选择引用,可以选择关系的类型,包括1v1、1v多、多v1等等。下面是 User 多对一 Article :

Untitled

5. 放开 权限

设置 → 角色 → public

开放文章查询权限:

Untitled

开放文章作者查询权限,否则连表查询的时候查不到作者信息:

Untitled

6. 接口测试

http://localhost:1337/api/articles

会发现只查到了文章列表:

{
  "data": [
    {
      "id": 6,
      "attributes": {
        "content": "test1test1test1\n\n# test1test1",
        "title": "test1",
        "desc": "test1test1",
        "createdAt": "2023-04-11T03:41:59.599Z",
        "updatedAt": "2023-04-11T03:47:21.010Z",
        "publishedAt": "2023-04-11T03:42:00.405Z"
      }
    }
  ],
  "meta": {
    "pagination": {
      "page": 1,
      "pageSize": 25,
      "pageCount": 1,
      "total": 1
    }
  }
}

需要添加参数进行连表查询:

http://localhost:1337/api/articles?populate=*
{
  "data": [
    {
      "id": 6,
      "attributes": {
        "content": "test1test1test1\n\n# test1test1",
        "title": "test1",
        "desc": "test1test1",
        "createdAt": "2023-04-11T03:41:59.599Z",
        "updatedAt": "2023-04-11T06:16:17.782Z",
        "publishedAt": "2023-04-11T03:42:00.405Z",
        "user": {
          "data": {
            "id": 3,
            "attributes": {
              "username": "mkmk",
              "email": "[email protected]",
              "provider": "local",
              "confirmed": true,
              "blocked": false,
              "createdAt": "2023-04-11T02:51:19.930Z",
              "updatedAt": "2023-04-11T02:51:19.930Z"
            }
          }
        },
        "tags": {
          "data": [
            {
              "id": 1,
              "attributes": {
                "label": "testTag",
                "createdAt": "2023-04-11T03:47:12.104Z",
                "updatedAt": "2023-04-11T03:47:12.680Z",
                "publishedAt": "2023-04-11T03:47:12.679Z"
              }
            },
            {
              "id": 2,
              "attributes": {
                "label": "testTag2",
                "createdAt": "2023-04-11T06:16:08.647Z",
                "updatedAt": "2023-04-11T06:16:09.256Z",
                "publishedAt": "2023-04-11T06:16:09.255Z"
              }
            }
          ]
        }
      }
    }
  ],
  "meta": {
    "pagination": {
      "page": 1,
      "pageSize": 25,
      "pageCount": 1,
      "total": 1
    }
  }
}