Skip to content

Bases 数据库速查表

Obsidian Bases 是 1.7.2+ 引入的内置数据库功能,无需插件即可创建结构化数据视图。

基本语法

创建数据库

markdown
```base
```

完整结构

markdown
```base
name: 我的数据库
description: 数据库描述
filters:
  - <筛选条件>
sorts:
  - <排序条件>
view:
  type: table
  columns:
    - <列配置>
```

数据来源

从文件夹读取

yaml
source: folder
path: "Projects"  # 文件夹路径

从标签读取

yaml
source: tag
tag: "project"  # 标签名(不含 #)

从查询读取

yaml
source: query
query: 'path:"Projects" AND status:"active"'

筛选器

属性筛选

yaml
filters:
  - property: status
    value: "in-progress"
  
  - property: priority
    value: "high"
  
  - property: due
    operator: before
    value: "2024-12-31"

运算符

运算符说明示例
equals等于status equals "done"
not_equals不等于status not_equals "archived"
contains包含tags contains "urgent"
not_contains不包含tags not_contains "draft"
before早于(日期)due before "2024-12-31"
after晚于(日期)created after "2024-01-01"
is_empty为空assignee is_empty
is_not_empty不为空assignee is_not_empty

组合筛选

yaml
filters:
  - condition: AND
    filters:
      - property: status
        value: "in-progress"
      - property: priority
        value: "high"

排序

单字段排序

yaml
sorts:
  - property: priority
    direction: desc

多字段排序

yaml
sorts:
  - property: priority
    direction: desc
  - property: due
    direction: asc

排序方向

方向说明
asc升序(A→Z, 1→9, 早→晚)
desc降序(Z→A, 9→1, 晚→早)

视图类型

表格视图

yaml
view:
  type: table
  columns:
    - property: file.name
      label: 名称
    - property: status
      label: 状态
    - property: priority
      label: 优先级
    - property: due
      label: 截止日期

看板视图

yaml
view:
  type: board
  groupBy: status
  columns:
    - property: file.name
    - property: priority
    - property: due

日历视图

yaml
view:
  type: calendar
  dateProperty: due
  columns:
    - property: file.name
    - property: status

画廊视图

yaml
view:
  type: gallery
  cardProperty: cover
  columns:
    - property: file.name
    - property: status

列配置

基本列

yaml
columns:
  - property: file.name
    label: 笔记名
    width: 200

列类型

类型说明
text文本
number数字
date日期
checkbox复选框
select单选
multi_select多选
url链接
file文件链接

格式化列

yaml
columns:
  - property: due
    label: 截止日期
    type: date
    format: "YYYY-MM-DD"
  
  - property: progress
    label: 进度
    type: number
    format: percentage

常用模板

任务看板

markdown
```base
name: 任务看板
source: tag
tag: "task"
view:
  type: board
  groupBy: status
  columns:
    - property: file.name
      label: 任务
    - property: priority
      label: 优先级
    - property: due
      label: 截止
sorts:
  - property: priority
    direction: desc
```

阅读列表

markdown
```base
name: 阅读列表
source: folder
path: "Reading"
view:
  type: table
  columns:
    - property: file.name
      label: 书名
    - property: author
      label: 作者
    - property: status
      label: 状态
    - property: rating
      label: 评分
    - property: date_read
      label: 阅读日期
filters:
  - property: status
    operator: not_equals
    value: "archived"
sorts:
  - property: date_read
    direction: desc
```

项目追踪

markdown
```base
name: 项目追踪
source: tag
tag: "project"
view:
  type: table
  columns:
    - property: file.name
      label: 项目名
    - property: status
      label: 状态
    - property: priority
      label: 优先级
    - property: start_date
      label: 开始日期
    - property: due_date
      label: 截止日期
    - property: progress
      label: 进度
filters:
  - property: status
    operator: not_equals
    value: "completed"
sorts:
  - property: priority
    direction: desc
  - property: due_date
    direction: asc
```

与 Dataview 对比

特性BasesDataview
内置❌(插件)
可视化编辑
看板视图
日历视图
查询语法YAMLDQL/JS
高级计算有限强大
跨笔记聚合有限强大

相关资源