# Obsidian Dataview
- [`blacksmithgu/obsidian-dataview`](https://github.com/blacksmithgu/obsidian-dataview)
- [Dataview full reference](https://blacksmithgu.github.io/obsidian-dataview/)
> [!tip]
>
> Use `LIST` query and `typeof()` function to facilitate debugging! Make
> sure types are compatible!
## Metadata
- Use inline metadata to include metadata semantically. e.g. `I would rate this film as \[rating:: 9\]`. (ignore backslash)
- Bracketed inline metadata is the only way to annotate a list item such as todo.
- Combined with inline tags and `TASK` query, this can be used for task management. Compare with [[obsidian-tasks]]
## Query Commands
- To reformat the date, use `date(file.cday, "yyyy-MM-dd")` -- note that this
function does not take `array`.
## Data Commands
### `GROUP BY`
- [An Introduction to Dataview - Part 1](https://www.youtube.com/watch?v=sEgzrRNkgsE&t=2957s),
the `GROUP BY` command.
- When grouped, the table becomes a [[nested]] structure, to get the rows we
want, we use `rows.file.name` to access the `rows` object.
- To adjust elements within the `rows` object, use
[`map()`](https://blacksmithgu.github.io/obsidian-dataview/reference/functions/#maparray-func)
function. See [[mooc-catalog]] for an example.
```sql
map(rows.file.cday, (x) => dateformat(x, "MMM, dd")) AS "Date"
```
- When the field is nested, may need to
[`flat()`](https://blacksmithgu.github.io/obsidian-dataview/reference/functions/#flatarray-depth)
them. See [[dashboard]] for example.
```sql
flat(rows.file.etags) AS Tags,
```
### `SORT`
- To sort notes within each group while using `GROUP BY`, make sure to put
`SORT` command before `GROUP BY` command. See [[mooc-catalog]] for example.
### `WHERE`
- In filtering `boolean` fields, `null` type is treated as `false`. Filter
`null` items out first if necessary. See [[dashboard]] for example.
## Functions
- Note that, some functions does not take `array` as input, they can't be used
on `rows` objects.