til / Obsidian Bases
Obsidian v1.9.0
, currently in beta, introduces a new core plugin called Bases. In the current iteration of my notes, I can replace all my needs for dataview.
For example, the notes created today example can be recreated using the following Bases code. To get to this code, you’ll need to open the *.base
file in a text editor. That’s at least the only way I’ve found so far.
It’s all very new and shiny, but I think this can be a great addition to Obsidian in the long run.
# This reflects the syntax as of 1.9.2
# Without filters, you'll see all the files in the vault.
# Use these to narrow down the files for the views.
filters:
# Any of the conditions can be true
or:
# Any file that links to this daily note
- file.hasLink(this.file.name)
# Any file that was created today
- date(created).format("YYYY-MM-DD") == this.file.name
# Formulas allows us to create custom data for the views
formulas:
# Format created time
created_time: created.format("HH:mm")
# If updated time is not date of daily note, display updated
# date and time. The if only has a 'trueResult'. If it
# evaluates to false it will display nothing.
updated_date: if(date(updated).format("YYYY-MM-DD") != this.file.name, updated.format("YYYY-MM-DD HH:mm"))
# Which properties to display and the prettified title to show in the header
properties:
file.name:
displayName: Note
formula.created_time:
displayName: Created
formula.updated_date:
displayName: Updated
# Views to display (currently only table exists)
views:
- type: table
name: Daily notes
# Same as filters above, but only applied to this view
filters:
# All filters need to be true
and:
# Files not tagged with "daily"
- '!file.hasTag("daily")'
# Order to display the columns
order:
- file.name
- formula.created_time
- formula.updated_date
# How to sort columns
# Sort by:
# - Our custom created_time ascending first
# - Then by the file name descending
sort:
- column: formula.created_time
direction: ASC
- column: file.name
direction: DESC