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 对比
| 特性 | Bases | Dataview |
|---|---|---|
| 内置 | ✅ | ❌(插件) |
| 可视化编辑 | ✅ | ❌ |
| 看板视图 | ✅ | ❌ |
| 日历视图 | ✅ | ❌ |
| 查询语法 | YAML | DQL/JS |
| 高级计算 | 有限 | 强大 |
| 跨笔记聚合 | 有限 | 强大 |
相关资源
- Bases 数据库 — 完整教程
- Dataview 速查表 — Dataview 查询参考
- 属性(Properties) — 笔记属性系统