---
> [!NOTE] 目次
```table-of-contents
title:
minLevel: 0
maxLevel: 0
includeLinks: true
```
---
> [!NOTE] リスト掲載用文字列
- [関数 - Obsidian ヘルプ](https://help.obsidian.md/bases/functions)【Obsidian Help】()
---
> [!NOTE] この記事の要約(箇条書き)
- Obsidianの「Bases」における関数は、プロパティのデータをフィルターや数式内で操作するために使用されます。
- 関数は、**グローバル**、**任意(Any)**、**日付(Date)**、**文字列(String)**、**数値(Number)**、**リスト(List)**、**リンク(Link)**、**ファイル(File)**、**オブジェクト(Object)**、**正規表現(Regexp)**のカテゴリに分類されます。
- **グローバル関数**は、`date()`, `file()`, `if()`, `image()`, `icon()`, `max()`, `min()`, `link()`, `list()`, `now()`, `number()`, `duration()`, `today()`など、型を指定せずに使用されます。
- **任意(Any)関数**は、`toString()`, `isTruthy()`など、あらゆる値の型に対して使用できます。
- **日付(Date)関数**は、日付のフィールド(年、月、日など)へのアクセス、`format()`, `time()`, `relative()`, `isEmpty()`といった操作を提供します。
- **文字列(String)関数**は、`length`フィールドや、`contains()`, `replace()`, `lower()`, `slice()`, `split()`, `trim()`などの操作を提供します。
- **数値(Number)関数**は、`abs()`, `ceil()`, `floor()`, `round()`, `toFixed()`などの数学的演算をサポートします。
- **リスト(List)関数**は、`length`フィールドや、`contains()`, `join()`, `reverse()`, `sort()`, `flat()`, `unique()`, `slice()`, `map()`, `filter()`などのリスト操作を提供します。
- **リンク(Link)関数**は、`linksTo()`, `asFile()`などでリンクされたファイルやパスを操作します。
- **ファイル(File)関数**は、`asLink()`, `hasLink()`, `hasProperty()`, `hasTag()`, `inFolder()`などでファイル自体のプロパティや関係をチェックします。
- **オブジェクト(Object)関数**は、`isEmpty()`, `keys()`, `values()`でキーと値のペアを扱います。
- **正規表現(Regexp)関数**は、`matches()`で文字列と正規表現パターンの照合を行います。
> [!NOTE] 要約おわり
---
[関数は、 Bases](https://help.obsidian.md/bases) で フィルターや数式内の [プロパティ](https://help.obsidian.md/properties) のデータを操作するために使用されます。 関数の使用方法の詳細については、 [Bases構文リファレンスをご覧ください。](https://help.obsidian.md/bases/syntax)
[グローバル](https://help.obsidian.md/bases/functions#Global) 関数を除き 、ほとんどの関数は変更する値の種類によって異なります。
## グローバル
グローバル関数は型なしで使用されます。
### date()
`date(date: string): date`
- `date(string): date` 提供された文字列を解析し、日付オブジェクトを返します。
- 文字 `date` 列は の形式にする必要があります `YYYY-MM-DD HH:mm:ss` 。
### file()
`file(path: string | file | url): file`
- 指定されたファイルまたはパスのファイル オブジェクトを返します。
- 例:`file(link("[[filename]]"))` または `file("path to file")` 。
### if()
`if(condition: any, trueResult: any, falseResult?: any): any`
- `condition` 評価される条件です。
- `trueResult` 条件が真の場合の出力です。
- `falseResult` は、条件が偽の場合のオプションの出力です。指定されていない場合は、 とみなされます `null` 。
- `trueResult` が true の場合 `condition` 、または真実の値の場合、またはそれ以外の場合 に を返します `falseResult` 。
- 例: `if(isModified, "Modified", "Unmodified")`
### image()
`image(path: string | file | url): image`
- ビューに画像をレンダリングする画像オブジェクトを返します。
- 例:`image(image-property)` または `image("https://obsidian.md/images/obsidian-logo-gradient.svg")`
### icon()
`icon(name: string): icon`
- ビュー内でアイコンとして表示される値を返します。アイコン名は、サポートされているLucideアイコンと一致する必要があります。
- 例: `icon("arrow-right")` 。
### max()
`max(value1: number, value2: number...): number`
- 指定されたすべての数値の中で最大の数値を返します。
### min()
`min(value1: number, value2: number...): number`
- 指定されたすべての数値の中で最小のものを返します。
### link()
`link(path: string | file, display?: value): Link`
- 文字列を解析し `path` 、指定されたパスへのリンクとしてレンダリングされる Link オブジェクトを返します。
- オプションで、 `display` リンクのテキストを変更するためのパラメータを指定します。
### list()
`list(element: any): List`
- 指定された要素がリストの場合は、変更せずに返します。
- それ以外の場合は、提供されたを `element` リストにラップして、単一の要素を持つリストを作成します。
- この関数は、プロパティにボールト全体で文字列またはリストが混在している場合に役立ちます。
- 例:`list("value")` を返します `["value"]` 。
### now()
`now(): date`
- `now()` 現在の瞬間を表す日付オブジェクトを返します。
### number()
`number(input: any): number`
- 提供された値を数値として返します。
- 日付オブジェクトは、Unix エポックからのミリ秒として返されます。
- ブール値は 1 または 0 を返します。
- 文字列は数値に解析され、結果が無効な場合はエラーが返されます。
- たとえば、 `number("3.4")` を返します `3.4` 。
### duration()
`duration(value: string): duration`
- 文字列を期間として解析します。文字列の形式 については、 [日付演算のセクション](https://help.obsidian.md/bases/syntax#Date%20arithmetic) `value` を参照してください。
- Durations do not need to be explicitly parsed when performing date arithmetic (for example, `now() + '1d'`), but the do when performing arithmetic on durations (for example, `now() + (duration('1d') * 2)`).
- When performing arithmetic on durations with scalars, the duration must be on the left. For example `duration('5h') * 2`, instead of `2 * duration('5h')`.
### today()
`today(): date`
- `today()` returns a date object representing the current date. The time portion is set to zero.
### date()
`date(input: string | date): date`
- Returns a date object representing the parsed input timestamp or date object.
## Any
Functions you can use with any value. This includes strings (e.g. `"hello"`), numbers (e.g. `42`), lists (e.g. `[1,2,3]`), objects, and more.
### toString()
`any.toString(): string`
- Returns the string representation of any value.
- Example: `123.toString()` returns `"123"`.
### isTruthy()
`any.isTruthy(): boolean`
- Return the value coerced into a boolean.
- Example: `1.isTruthy()` returns `true`.
## Date
Functions you can use with a date and time such as `date("2025-05-27")`. Date comparisons can be done using [date arithmetic](https://help.obsidian.md/bases/syntax#Date%20arithmetic).
### Fields
The following fields are available for dates:
| Field | Type | Description |
| --- | --- | --- |
| `date.year` | `number` | The year of the date |
| `date.month` | `number` | The month of the date (1–12) |
| `date.day` | `number` | The day of the month |
| `date.hour` | `number` | The hour (0–23) |
| `date.minute` | `number` | The minute (0–59) |
| `date.second` | `number` | The second (0–59) |
| `date.millisecond` | `number` | The millisecond (0–999) |
### date()
`date.date(): date`
- Returns a date object with the time removed.
- Example: `now().date().format("YYYY-MM-DD HH:mm:ss"` returns a string such as "2025-12-31 00:00:00"
### format()
`date.format(format: string): string`
- `format` is the format string (e.g., `"YYYY-MM-DD"`).
- Returns the date formatted as specified by a Moment.js format string.
- Example: `date.format("YYYY-MM-DD")` returns `"2025-05-27"`.
### time()
`date.time(): string`
- Returns the time.
- Example: `now().time()` returns a string such as "23:59:59"
### relative()
`date.relative(): string`
- Returns a readable comparison of the date to the current datetime.
- Example: `file.mtime.relative()` returns a value such as `3 days ago`.
### isEmpty()
`date.isEmpty(): boolean`
- Returns false.
## String
Functions you can use with a sequence of characters such as `"hello".`
### Fields
| Field | Type | Description |
| --- | --- | --- |
| `string.length` | `number` | The number of characters in the string |
### contains()
`string.contains(value: string): boolean`
- `value` is the substring to search for.
- Returns true if the string contains `value`.
- Example: `"hello".contains("ell")` returns `true`.
### containsAll()
`string.containsAll(...values: string): boolean`
- `values` are one or more substrings to search for.
- Returns true if the string contains all of the `values`.
- Example: `"hello".containsAll("h", "e")` returns `true`.
### containsAny()
`string.containsAny(...values: string): boolean`
- `values` are one or more substrings to search for.
- Returns true if the string contains at least one of the `values`.
- Example: `"hello".containsAny("x", "y", "e")` returns `true`.
### endsWith()
`string.endsWith(query: string): boolean`
- `query` is the string to check at the end.
- Returns true if this string ends with `query`.
- Example: `"hello".endsWith("lo")` returns `true`.
### isEmpty()
`string.isEmpty(): boolean`
- Returns true if the string has no characters, or is not present.
- Example: `"Hello world".isEmpty()` returns `false`.
- Example: `"".isEmpty()` returns `true`.
### replace()
`string.replace(pattern: string | Regexp, replacement: string): string`
- `pattern` is the value to search for in the target string.
- `replacement` is the value to replace found patterns with.
- If `pattern` is a string, all occurrences of the pattern will be replaced.
- If `pattern` is a Regexp, the `g` flag determines if only the first or if all occurrences are replaced.
- Example: `"a,b,c,d".replace(/,/, "-")` returns `"a-b,c,d"`, where as `"a,b,c,d".replace(/,/g, "-")` returns `"a-b-c-d"`.
### lower()
`string.lower(): string`
- Returns the string converted to lower case.
### reverse()
`string.reverse(): string`
- Reverses the string.
- Example: `"hello".reverse()` returns `"olleh"`.
### slice()
`string.slice(start: number, end?: number): string`
- `start` is the inclusive start index.
- `end` is the optional exclusive end index.
- Returns a substring from `start` (inclusive) to `end` (exclusive).
- Example: `"hello".slice(1, 4)` returns `"ell"`.
- If `end` is omitted, slices to the end of the string.
### split()
`string.split(separator: string | Regexp, n?: number): list`
- `separator` is the delimiter for splitting the string.
- `n` is an optional number. If provided, the result will have the first `n` elements.
- Returns an list of substrings.
- Example: `"a,b,c,d".split(",", 3)` or `"a,b,c,d".split(/,/, 3)` returns `["a", "b", "c"]`.
### startsWith()
`string.startsWith(query: string): boolean`
- `query` is the string to check at the beginning.
- Returns true if this string starts with `query`.
- Example: `"hello".startsWith("he")` returns `true`.
### title()
`string.title(): string`
- Converts the string to title case (first letter of each word capitalized).
- Example: `"hello world".title()` returns `"Hello World"`.
### trim()
`string.trim(): string`
- Removes whitespace from both ends of the string.
- Example: `" hi ".trim()` returns `"hi"`.
## Number
Functions you can use with numeric values such as `42`, `3.14`.
### abs()
`number.abs(): number`
- Returns the absolute value of the number.
- Example: `(-5).abs()` returns `5`.
### ceil()
`number.ceil(): number`
- Rounds the number up to the nearest integer.
- Example: `(2.1).ceil()` returns `3`.
### floor()
`number.floor(): number`
- Rounds the number down to the nearest integer.
- Example: `(2.9).floor()` returns `2`.
### round()
`number.round(digits: number): number`
- Rounds the number to the nearest integer.
- Optionally, provided a `digits` parameter to round to that number of decimal digits.
- Example: `(2.5).round()` returns `3`, and `(2.3333).round(2)` returns `2.33`.
### toFixed()
`number.toFixed(precision: number): string`
- `precision` is the number of decimal places.
- Returns a string with the number in fixed-point notation.
- Example: `(3.14159).toFixed(2)` returns `"3.14"`.
### isEmpty()
`number.isEmpty(): boolean`
- Returns true if the number is not present.
- Example: `5.isEmpty()` returns `false`.
## List
Functions you can use with an ordered list of elements such as `[1, 2, 3]`.
### Fields
| Field | Type | Description |
| --- | --- | --- |
| `list.length` | `number` | The number of elements in the list |
### contains()
`list.contains(value: any): boolean`
- `value` is the element to search for.
- Returns true if the list contains `value`.
- Example: `[1,2,3].contains(2)` returns `true`.
### containsAll()
`list.containsAll(...values: any): boolean`
- `values` are one or more elements to search for.
- Returns true if the list contains all of the `values`.
- Example: `[1,2,3].containsAll(2,3)` returns `true`.
### containsAny()
`list.containsAny(...values: any): boolean`
- `values` are one or more elements to search for.
- Returns true if the list contains at least one of the `values`.
- Example: `[1,2,3].containsAny(3,4)` returns `true`.
### isEmpty()
`list.isEmpty(): boolean`
- Returns true if the list has no elements.
- Example: `[1,2,3].isEmpty()` returns `false`.
### join()
`list.join(separator: string): string`
- `separator` is the string to insert between elements.
- Joins all list elements into a single string.
- Example: `[1,2,3].join(",")` returns `"1,2,3"`.
### reverse()
`list.reverse(): list`
- Reverses the list in place.
- Example: `[1,2,3].reverse()` returns `[3,2,1]`.
### sort()
`list.sort(): list`
- Sorts list elements from smallest to largest.
- Example: `[3, 1, 2].sort()` returns `[1, 2, 3]`.
- Example: `["c", "a", "b"].sort()` returns `["a", "b", "c"]`.
### flat()
`list.flat(): list`
- Flattens nested list into a single list.
- Example: `[1,[2,3]].flat()` returns `[1,2,3]`.
### unique()
`list.unique(): list`
- Removes duplicate elements.
- Example: `[1,2,2,3].unique()` returns `[1,2,3]`.
### slice()
`list.slice(start: number, end?: number): list`
- `start` is the inclusive start index.
- `end` is the optional exclusive end index.
- Returns a shallow copy of a portion of the list from `start` (inclusive) to `end` (exclusive).
- Example: `[1,2,3,4].slice(1,3)` returns `[2,3]`.
- If `end` is omitted, slices to the end of the list.
### map()
`list.map(value: Any): list`
- Transform each element of this list by calling a conversion function, which uses the variables `index` and `value`, and returns the new value to be placed in the list.
- `value` is the value of an item in the list.
- `index` is the index of the current value.
- Example: `[1,2,3,4].map(value + 1)` returns `[2,3,4,5]`.
### filter()
`list.filter(value: Boolean): list`
- Filter the elements of this list by calling a filter function, which uses the variables `index` and `value`, and returns a boolean value for whether the element should be kept.
- `value` is the value of an item in the list.
- `index` is the index of the current value.
- Example: `[1,2,3,4].filter(value > 2)` returns `[3,4]`.
## Link
Functions you can use on a link. Links can be created from a file (`file.asLink()`) or a path (`link("path")`).
### linksTo()
`link.linksTo(file): boolean`
- Returns whether the file represented by the `link` has a link to `file`.
### asFile()
`link.asFile(): file`
- Returns a file object if the link refers to a valid local file.
- Example: `link("[[filename]]").asFile()`
## File
Functions you can use with file in the vault.
### asLink()
`file.asLink(display?: string): Link`
- `display` optional display text for the link.
- Returns a Link object that renders as a functioning link.
- Example: `file.asLink()`
### hasLink()
`file.hasLink(otherFile: file | string): boolean`
- `otherFile` is another file object or string path to check.
- Returns true if `file` links to `otherFile`.
- 例:から へ のリンクがある場合に `file.hasLink(otherFile)` を返します 。 `true` `file` `otherFile`
### hasProperty()
`file.hasProperty(name: string): boolean`
- ノートに指定されたファイル プロパティがある場合は true を返します。
### hasTag()
`file.hasTag(...values: string): boolean`
- `values` 1 つ以上のタグ名です。
- ファイルに のいずれかのタグが含まれている場合は true を返します `values` 。
- 例:ファイルにいずれかのタグがあるかどうか `file.hasTag("tag1", "tag2")` を返します。 `true`
### inFolder()
`file.inFolder(folder: string): boolean`
- `folder` チェックするフォルダ名です。
- ファイルが指定されたフォルダー内にある場合は true を返します。
- 例:`file.inFolder("notes")` を返します `true` 。
## 物体
などのキーと値のペアのコレクションで使用できる関数 `{"a": 1, "b": 2}` 。
### isEmpty()
`object.isEmpty(): boolean`
- オブジェクトに独自のプロパティがない場合には true を返します。
- 例:`{}.isEmpty()` を返します `true` 。
### keys()
`object.keys(): list`
- オブジェクトのキーを含むリストを返します。
### values()
`object.values(): list`
- オブジェクトの値を含むリストを返します。
## 正規表現
正規表現パターンで使用できる関数。例: `/abc/`.
### matches()
`regexp.matches(value: string): boolean`
- `value` テストする文字列です。
- 正規表現が一致する場合は true を返します `value` 。
- 例:`/abc/.matches("abcde")` を返します `true` 。