Loving Tina? us on GitHub0.0k

文档

学习

v.Latest
Documentation
概述
目录

特定模式查询

当您定义一个模式时,TinaCMS将生成一个GraphQL API,将您的本地文件系统视为数据库。您可以通过CLI在本地提供此模式,或者从TinaCloud中使用它。

GraphQL API将生成特定于您定义的模式的查询。

可用查询

  • <collection>
  • <collection>Connection

可用变更

  • update<collection>
  • addPendingDocument

对于给定的集合,其name将用于生成<collection><collection>Connection查询,以及update<collection>变更。

通用查询

作为特定模式查询的替代方案,GraphQL API还提供以下通用查询:

  • document
  • collection
  • collections
  • addPendingDocument
  • updateDocument

示例模式

使用以下模式,我们将向您展示如何使用每个特定模式的查询/变更。

import { defineConfig } from 'tinacms'
export default defineConfig({
// ...
schema: {
collections: [
{
label: '博客文章',
name: 'post',
path: 'content/posts',
format: 'json',
fields: [
{
type: 'string',
label: '标题',
name: 'title',
},
{
type: 'string',
label: '类别',
name: 'category',
},
{
type: 'datetime',
label: '日期',
name: 'date',
},
{
type: 'reference',
label: '作者',
name: 'author',
collections: ['author'],
},
],
indexes: [
{
name: 'category-date',
fields: [{ name: 'category' }, { name: 'date' }],
},
],
},
{
label: '作者',
name: 'author',
format: 'json',
path: 'content/authors',
fields: [
{
type: 'string',
label: '姓名',
name: 'name',
},
{
type: 'string',
label: '头像',
name: 'avatar',
},
],
},
],
},
})
上次编辑: June 16, 2025