{"id":812,"date":"2025-02-07T04:03:41","date_gmt":"2025-02-06T20:03:41","guid":{"rendered":"https:\/\/yanghaixiong.com\/?p=812"},"modified":"2025-02-07T04:03:41","modified_gmt":"2025-02-06T20:03:41","slug":"obsidian%e6%8f%92%e4%bb%b6dataview-dataarray%e6%8e%a5%e5%8f%a3%e4%bb%8b%e7%bb%8d%ef%bc%88%e4%b9%9d%ef%bc%89","status":"publish","type":"post","link":"https:\/\/yanghaixiong.com\/blog\/skills\/812\/","title":{"rendered":"Obsidian\u63d2\u4ef6Dataview \u2014\u2014 DataArray\u63a5\u53e3\u4ecb\u7ecd\uff08\u4e5d\uff09"},"content":{"rendered":"
\u8fd9\u7bc7\u6587\u7ae0\u662f Obsidian Dataview \u7cfb\u5217<\/a> \u7cfb\u5217 15 \u7bc7\u6587\u7ae0\u4e2d\u7684\u7b2c 9 \u7bc7<\/div>\n

DataArray<\/code> \u63a5\u53e3\u662f Dataview \u63d0\u4f9b\u7684\u5217\u8868\u6570\u636e\u64cd\u4f5c\u7684\u62bd\u8c61\uff0c\u5b83\u662f\u5bf9 JavaScript \u6570\u7ec4\u64cd\u4f5c\u7684\u6269\u5c55\u548c\u57fa\u4e8e Dataview \u73af\u5883\u7684\u672c\u5730\u5316\u3002\u6211\u4eec\u53ef\u8fc7 dv.array()<\/code> \u5c06\u4e00\u4e2a\u666e\u901a\u7684\u6570\u7ec4\u8f6c\u6362\u6210 DataArray<\/code> \u7c7b\u578b\uff0c\u4e5f\u53ef\u4ee5\u53cd\u5411\u64cd\u4f5c\u5c06\u5176\u8f6c\u6362\u6210\u666e\u901a\u7684 JavaScript \u6570\u7ec4\uff0c\u6bd4\u5982\uff1adv.list(dv.current()).array()<\/code>\u3002<\/p>\n

\u4e0b\u9762\u662f\u5b98\u65b9\u63d0\u4f9b\u7684 DataArray<\/code> \u63a5\u53e3\u5b9a\u4e49\uff0c\u4e3a\u4e86\u7b80\u5c11\u884c\u6570\uff0c\u5220\u9664\u4e86\u6240\u6709\u6ce8\u91ca\uff1a<\/p>\n

export type ArrayFunc<T, O> = (elem: T, index: number, arr: T[]) => O;\nexport type ArrayComparator<T> = (a: T, b: T) => number;\nexport interface DataArray<T> {\n    length: number;\n    where(predicate: ArrayFunc<T, boolean>): DataArray<T>;\n    filter(predicate: ArrayFunc<T, boolean>): DataArray<T>;\n    map<U>(f: ArrayFunc<T, U>): DataArray<U>;\n    flatMap<U>(f: ArrayFunc<T, U[]>): DataArray<U>;\n    mutate(f: ArrayFunc<T, any>): DataArray<any>;\n    limit(count: number): DataArray<T>;\n    slice(start?: number, end?: number): DataArray<T>;\n    concat(other: Iterable<T>): DataArray<T>;\n    indexOf(element: T, fromIndex?: number): number;\n    find(pred: ArrayFunc<T, boolean>): T | undefined;\n    findIndex(pred: ArrayFunc<T, boolean>, fromIndex?: number): number;\n    includes(element: T): boolean;\n    join(sep?: string): string;\n    sort<U>(key: ArrayFunc<T, U>, direction?: \"asc\" | \"desc\", comparator?: ArrayComparator<U>): DataArray<T>;\n    groupBy<U>(key: ArrayFunc<T, U>, comparator?: ArrayComparator<U>): DataArray<{ key: U; rows: DataArray<T> }>;\n    distinct<U>(key?: ArrayFunc<T, U>, comparator?: ArrayComparator<U>): DataArray<T>;\n    every(f: ArrayFunc<T, boolean>): boolean;\n    some(f: ArrayFunc<T, boolean>): boolean;\n    none(f: ArrayFunc<T, boolean>): boolean;\n    first(): T;\n    last(): T;\n    to(key: string): DataArray<any>;\n    expand(key: string): DataArray<any>;\n    sum(): number;\n    avg(): number;\n    min(): number;\n    max(): number;\n    forEach(f: ArrayFunc<T, void>): void;\n    array(): T[];\n    [Symbol.iterator](): Iterator<T>;\n    [index: number]: any;\n    [field: string]: any;\n}\n<\/code><\/pre>\n

\u63a5\u4e0b\u6765\u6211\u4eec\u5c06\u5206\u7c7b\u4ecb\u7ecd\u63a5\u53e3\u4e2d\u7684\u5c5e\u6027\u548c\u65b9\u6cd5\u7684\u7528\u6cd5\u3002<\/p>\n

\u4e00\u3001\u6570\u636e\u8bfb\u53d6<\/h2>\n

\u4e00\u4e2a\u6570\u7ec4\u901a\u8fc7\u7d22\u5f15\u6765\u83b7\u53d6\u5176\u5bf9\u5e94\u7684\u6570\u636e\u9879\u7684\u503c\u662f\u4e00\u4e2a\u5f88\u5e38\u89c4\u7684\u64cd\u4f5c\u3002\u8fd9\u91cc\u6211\u4eec\u6709\u4e00\u4e2a\u6570\u7ec4 arr<\/code>\uff0c\u5c31\u53ef\u4ee5\u901a\u8fc7 arr[0]<\/code> \u548c arr[arr.length - 1]<\/code> \u6765\u5206\u522b\u8bfb\u53d6\u7b2c\u4e00\u9879\u548c\u6700\u540e\u4e00\u9879\u7684\u503c\uff0c\u8fd9\u5bf9\u5e94 DataArray<\/code> \u4e2d\u7684 first()<\/code> \u548c last()<\/code> \u65b9\u6cd5\u3002\u5982\u679c\u6570\u7ec4\u9879\u662f\u4e00\u4e2a\u5bf9\u8c61\u503c\uff0c\u60f3\u8981\u83b7\u53d6\u8bfb\u53d6\u5bf9\u8c61\u4e2d\u67d0\u4e2a\u5b57\u6bb5\u7684\u503c\uff0c\u5c31\u9700\u8981\u4f7f\u7528\u904d\u5386\u65b9\u6cd5\uff0c\u6bd4\u5982 for<\/code> \u8bed\u53e5\uff0c\u6216\u8005\u6570\u7ec4\u7684 forEach()<\/code> \u65b9\u6cd5\uff0c\u4e3a\u4e86\u65b9\u4fbf\u64cd\u4f5c\uff0cDataArray<\/code> \u63a5\u53e3\u76f4\u63a5\u63d0\u4f9b\u4e86\u4e00\u4e2a\u901a\u8fc7\u5c5e\u6027\u6765\u83b7\u53d6\u6570\u7ec4\u4e2d\u5bf9\u8c61\u503c\u7684\u65b9\u6cd5 to()<\/code>\uff0c\u4e5f\u53ef\u4ee5\u5728 DataArray<\/code> \u5b9e\u4f8b\u4e2d\u76f4\u63a5\u8bbf\u95ee\u8fd9\u4e2a\u5c5e\u6027\u540d\u3002<\/p>\n

```dataviewjs\nconst arr = [1, 2, 3]\nconst arr2 = [{name: 'jenemy', age: 34}, {name: 'xiaolu', age: 33}, {name: 'lulu', age: 25 }]\n\nconst dvArr = dv.array(arr)\nconst dvObjArr = dv.array(arr2)\n\nconsole.log(dvArr.length) \/\/ 3\nconsole.log(dvArr.first(), dvArr.last()) \/\/ 1 3\nconsole.log(dvArr[0], dvArr[dvArr.length - 1]) \/\/ 1 3\n\nconsole.log(dvObjArr.name.array()) \/\/ ['jenemy', 'xiaolu', 'lulu']\nconsole.log(dvObjArr['name'].array()) \/\/ ['jenemy', 'xiaolu', 'lulu']\nconsole.log(dvObjArr.to('name').array()) \/\/ ['jenemy', 'xiaolu', 'lulu']\nconsole.log(dvObjArr[0]) \/\/ {name: 'jenemy', age: 34}\n\n\/\/ \u901a\u8fc7\u904d\u5386\u83b7\u53d6\u5c5e\u6027\u503c\nfor (p of dvObjArr) {\n    console.log(p.name) \/\/ jenemy, xiaolu, lulu\n}\n\n\/\/ \u4f7f\u7528 `.forEach()` \u904d\u5386\ndvObjArr.forEach(p => console.log(p.name)) \/\/ jenemy, xiaolu, lulu\n<\/code><\/pre>\n

\u4e8c\u3001\u6570\u5b57\u8fd0\u7b97<\/h2>\n

\u63d0\u4f9b\u4e86\u5bf9\u4e8e\u6570\u5b57\u7684\u51e0\u4e2a\u5e38\u89c1\u8fd0\u7b97\uff0c\u5982\u6c42\u548c\u3001\u6c42\u5e73\u5747\u503c\u3001\u6700\u5927\u503c\u548c\u6700\u5c0f\u503c\u3002\u8fd9\u4e2a\u548c DQL \u67e5\u8be2\u8bed\u8a00\u4e2d\u7684\u529f\u80fd\u4e00\u81f4\u3002<\/p>\n

```dataviewjs\nconst arr = dv.array([2, 3, 1, 8, 4, 6, 5, 7, 9])\nconsole.log(arr.sum()) \/\/ 15\nconsole.log(arr.min()) \/\/ 1\nconsole.log(arr.max()) \/\/ 9\nconsole.log(arr.avg()) \/\/ 5\n<\/code><\/pre>\n

\u4e09\u3001\u6570\u636e\u904d\u5386<\/h2>\n

\u6570\u636e\u904d\u5386\u9664\u4e86\u4f7f\u7528\u00a0for<\/code>\u00a0\u548c\u00a0for of<\/code>\u00a0\u8bed\u53e5\u5916\uff0cDataArray<\/code>\u00a0\u63a5\u53e3\u4e2d\u8fd8\u5b9a\u4e49\u4e86\u5f88\u591a\u904d\u5386\u65b9\u6cd5\uff0c\u6709\u7684\u662f JavaScript \u4e2d\u76f8\u540c\u7684\uff0c\u6709\u7684\u662f Dataview \u7279\u6709\u7684\u3002<\/p>\n

1. forEach()\u65b9\u6cd5<\/h3>\n

\u65b9\u6cd5\u7b7e\u540d\u4e3a\uff1aforEach(f: ArrayFunc<T, void>): void<\/code>\uff0c\u5bf9\u6570\u7ec4\u7684\u6bcf\u4e00\u9879\u6267\u884c\u6307\u5b9a\u7684\u51fd\u6570\u3002<\/p>\n

```dataviewjs\ndv.array([1, 2, 3, 4, 5]).forEach(n => dv.span(n)) \/\/ \u9875\u9762\u663e\u793a\uff1a12345\n<\/code><\/pre>\n

2. map()\u65b9\u6cd5<\/h3>\n

\u65b9\u6cd5\u7b7e\u540d\u4e3a\uff1amap<U>(f: ArrayFunc<T, U>): DataArray<U><\/code>\uff0c\u5bf9\u6570\u7ec4\u4e2d\u7684\u6bcf\u4e00\u9879\u6267\u884c\u6307\u5b9a\u7684\u51fd\u6570\uff0c\u5e76\u8fd4\u56de\u4e00\u4e2a\u503c\u3002<\/p>\n

```dataviewjs\ndv.list(dv.array([1, 2, 3, 4, 5]).map(x => x * 2)) \/\/ \u6e32\u67d3\u5217\u8868\uff1a2, 4, 6, 8, 10\ndv.list(dv.array([1, 2, 3, 4, 5]).map(x => x % 2 === 0)) \/\/ \u6e32\u67d3\u5217\u8868\uff1afalse, true, false, true, false\n<\/code><\/pre>\n

3. mutate()\u65b9\u6cd5<\/h3>\n

\u65b9\u6cd5\u7b7e\u540d\u4e3a\uff1amutate(f: ArrayFunc<T, any>): DataArray<any><\/code>\uff0c\u8fd9\u4e2a\u65b9\u6cd5\u5b9e\u9645\u4e0a\u662f\u5bf9 map()<\/code> \u904d\u5386\u5bf9\u8c61\u6570\u7ec4\u64cd\u4f5c\u7684\u4e00\u79cd\u7279\u5b9a\u573a\u666f\u4e0b\u7684\u7b80\u5316\u64cd\u4f5c\u3002<\/p>\n

\u4e0b\u9762\u6211\u4eec\u4e00\u6b65\u6b65\u6765\u8ffd\u672c\u6eaf\u6e90\uff0c\u89e3\u8bfb\u5176\u9002\u7528\u7684\u573a\u666f\u3002<\/p>\n

\u6211\u4eec\u77e5\u9053\u4f7f\u7528 map()<\/code> \u65b9\u6cd5\u53ef\u4ee5\u5bf9\u666e\u901a\u6570\u7ec4\uff08\u5982\uff1a[1, 2, 3, 4]<\/code>\uff09\uff0c\u6267\u884c\u904d\u5386\u64cd\u4f5c\u5982\uff1ax => x * 2<\/code> \u6216\u8005 x => x % 2 === 0<\/code> \u6765\u8fd4\u56de\u5e03\u5c14\u503c\uff0c\u4f46\u662f\u6211\u4eec\u65e0\u6cd5\u4f7f\u7528 mutate()<\/code> \u6765\u5b9e\u73b0\u540c\u6837\u7684\u529f\u80fd\u3002<\/p>\n

\u63a5\u4e0b\u6765\u6211\u4eec\u770b\u4e00\u4e0b\u5bf9\u8c61\u6570\u7ec4\uff08\u5982\uff1aconst arr = [{a: 1, b: 2}, {a: 3, b: 4}, {a: 5, b: 6}]<\/code>\uff09\uff0c\u4f7f\u7528 map()<\/code> \u65b9\u6cd5\u6211\u4eec\u53ef\u4ee5\u6267\u884c\u64cd\u4f5c x => x.a + x.b<\/code>\uff0c\u4f46\u662f\u540c\u6837\u5728 mutate()<\/code> \u65b9\u6cd5\u4e2d\u65e0\u6cd5\u4f7f\u7528\u3002\u63a5\u4e0b\u6765\u901a\u8fc7 map()<\/code> \u65b9\u6cd5\u4e3a\u5bf9\u8c61\u6dfb\u52a0\u4e00\u4e2a\u5c5e\u6027 c<\/code>\uff0c\u4ee3\u7801\u4e3a\uff1ax => {x.c = x.a + x.b; return x}<\/code>\uff0c\u7136\u540e\u6211\u4eec\u8fd9\u6b21\u53d1\u73b0\u53ef\u4ee5\u4f7f\u7528 mutate()<\/code> \u53d1\u6325\u4f5c\u7528\u4e86\uff1aarr.mutate(x => x.c = x.a + x.b)<\/code>\uff0c\u8fdb\u4e00\u6b65\u6211\u4eec\u5c1d\u8bd5\uff1aarr.mutate(x => delete x.b)<\/code> \u4ee5\u53ca arr.mutate(x => x.b = x.a + x.b)<\/code>\u3002<\/p>\n

\u603b\u7ed3<\/strong>\uff1amutate()<\/code> \u65b9\u6cd5\u9002\u7528\u4e8e\u4fee\u6539\u904d\u5386\u9879\uff08\u4ec5\u5bf9\u8c61\uff09\u7684\u503c\uff0c\u5982\u6dfb\u52a0\u5c5e\u6027\u3001\u5220\u9664\u5c5e\u6027\u4ee5\u53ca\u4fee\u6539\u5c5e\u6027\u503c\u64cd\u4f5c\u3002\u5b83\u662f\u5728\u4e0d\u6539\u53d8\u904d\u5386\u9879\u6570\u636e\u7c7b\u578b\u60c5\u51b5\u4e0b\uff0cmap()<\/code> \u65b9\u6cd5\u7684\u4e00\u79cd\u7b80\u5316\u64cd\u4f5c\u3002<\/p>\n

\u4e0b\u9762\u6211\u4eec\u770b\u4e00\u4e0b\u5728\u5b9e\u9645\u64cd\u4f5c\u4e2d\u7684\u8fd0\u7528\u3002<\/p>\n

```dataviewjs\ndv.table([\"File\", \"Author\", \"Book topics\", \"Genres\", \"Progress\"], dv.pages('\"10 Example Data\/books\"')\n    .mutate(b => b.percent = (b.pagesRead \/ b.totalPages * 100).toFixed(2) + \"%\")\n    .map(b => [b.file.link, b.author, b.booktopics, b.genres, b.percent]))\n<\/code><\/pre>\n

\u7ed3\u679c\uff1a
\n \"\"<\/p>\n

4. flatMap()\u65b9\u6cd5<\/h3>\n

\u65b9\u6cd5\u7b7e\u540d\u4e3a\uff1aflatMap<U>(f: ArrayFunc<T, U[]>): DataArray<U><\/code>\uff0c\u901a\u8fc7\u5bf9\u6570\u636e\u6570\u7ec4\u4e2d\u7684\u5143\u7d20\u5e94\u7528\u51fd\u6570\u6765\u6620\u5c04\u6bcf\u4e2a\u5143\u7d20\uff0c\u7136\u540e\u5c55\u5e73\u7ed3\u679c\u4ee5\u751f\u6210\u65b0\u6570\u7ec4\u3002<\/p>\n

\u8fd9\u662f\u4e00\u4e2a\u5f88\u91cd\u8981\u7684\u65b9\u6cd5\uff0c\u5e94\u7528\u5f97\u5f53\u5728\u5f88\u591a\u573a\u666f\u4e0b\u80fd\u591f\u7b80\u5316\u64cd\u4f5c\uff0c\u4f46\u662f\u8fd9\u4e2a\u65b9\u6cd5\u521d\u6b21\u63a5\u89e6\u6709\u70b9\u4e0d\u597d\u7406\u89e3\uff0c\u4e0b\u9762\u6211\u4eec\u6765\u4e00\u4e00\u89e3\u8bfb\u5176\u7528\u6cd5\u3002<\/p>\n

\u9996\u5148\u6211\u4eec\u5c06\u5728 mutate()<\/code> \u65b9\u6cd5\u8bb2\u89e3\u65f6\u6211\u4eec\u4f7f\u7528\u7684\u7b80\u5355\u6570\u7ec4 [1, 2, 3, 4]<\/code> \u548c const arr = [{a: 1, b: 2}, {a: 3, b: 4}, {a: 5, b: 6}]<\/code> \u4f7f\u7528 flatMap()<\/code> \u65b9\u6cd5\u8fdb\u884c\u540c\u6837\u64cd\u4f5c\uff1a<\/p>\n

```dataviewjs\nconst arr = dv.array([{a: 1, b: 2}, {a: 3, b: 4}, {a: 5, b: 6}])\n\ndv.list(dv.array([1, 2, 3, 4]).flatMap(x => [x * 2])) \/\/ \u9875\u9762\u663e\u793a [2, 4, 6, 8]\ndv.list(dv.array([1, 2, 3, 4]).flatMap(x => [x % 2 === 0])) \/\/ \u9875\u9762\u663e\u793a [false, true, false, true]\n\ndv.list(arr.flatMap(x => [x.a + x.b])) \/\/ \u9875\u9762\u663e\u793a [3, 7, 11]\ndv.list(arr.flatMap(x => {x.c = x.a + x.b; return [x]})) \/\/ \u9875\u9762\u663e\u793a [{a: 1, b: 2, c: 3}, {a: 3, b: 4, c: 7}, {a: 5, b: 6, c: 11}]\n<\/code><\/pre>\n

\u7ed3\u679c\uff1a
\n \"\"<\/p>\n

\u4ece\u4e0a\u9762\u7684\u793a\u4f8b\u53ef\u4ee5\u770b\u51fa\uff0c\u4f7f\u7528 flatMap()<\/code> \u65b9\u6cd5\u6539\u5199 map()<\/code> \u65b9\u6cd5\u53ea\u9700\u8981\u5c06\u7ed3\u679c\u5957\u4e0a\u4e00\u5c42\u6570\u7ec4\u3002<\/p>\n

\u8bfb\u8005\u53ef\u80fd\u4f1a\u7591\u60d1\uff0c\u5c31\u8fd9\u8fd8\u9700\u8981\u5355\u72ec\u641e\u4e00\u4e2a\u65b9\u6cd5\u51fa\u6765\u591a\u6b64\u4e00\u4e3e\u5417\uff1f\u5176\u5b9e\u4e0d\u7136\uff0c\u4e0b\u9762\u6211\u4eec\u6765\u63ed\u793a\u5176\u771f\u6b63\u53d1\u6325\u4f5c\u7528\u7684\u5730\u65b9\u3002<\/p>\n

\u5728\u4f7f\u7528 map()<\/code> \u65b9\u6cd5\u65f6\u4e0d\u4f1a\u6539\u53d8\u6570\u7ec4\u7684\u957f\u5ea6\uff0c\u8fd9\u662f\u4e00\u4e2a\u5171\u8bc6\u3002\u73b0\u5728\u6211\u60f3\u628a\u6570\u7ec4 [1, 2, 3, 4]<\/code> \u53d8\u6210 [1, 2, [3], 2, 3, [5], 3, 4, [7]]<\/code>\uff0c\u5176\u4e2d\u5d4c\u5957\u6570\u7ec4\u503c\u4e3a\u7b2c i<\/code> \u9879\u52a0\u4e0a i + 1<\/code> \u9879\u7684\u503c\uff0c\u5176\u4e2d i<\/code> \u4e3a\u6570\u7ec4\u7d22\u5f15\u3002\u8fd9\u4e2a\u65f6\u5019\u5c31\u65e0\u6cd5\u4f7f\u7528 map()<\/code> \u6765\u5b9e\u73b0\u4e86\uff0c\u9700\u8981\u4f7f\u7528 for<\/code> \u8bed\u53e5\u6216\u8005 forEach()<\/code> \u65b9\u6cd5\u6765\u904d\u5386\u6570\u7ec4\uff0c\u7136\u540e\u58f0\u660e\u4e00\u4e2a\u65b0\u7684\u6570\u7ec4\u6765\u5b58\u653e\u7ed3\u679c\uff1a<\/p>\n

```dataviewjs\nconst arr = dv.array([1, 2, 3, 4])\nconst result = []\nfor (let i = 0; i < arr.length; i++) {\n    if (i < arr.length - 1) {\n        result.push(arr[i], arr[i + 1], [arr[i] + arr[i + 1]])\n    }\n}\nconsole.log(result) \/\/ [1, 2, [3], 2, 3, [5], 3, 4, [7]]\n<\/code><\/pre>\n

\u90a3\u4e48\u4f7f\u7528 flatMap()<\/code> \u5b9e\u73b0\u5982\u4f55\u5462\uff1f<\/p>\n

\u5f88\u7b80\u5355\uff0c\u53ea\u9700\u8981\u4e00\u884c\u4ee3\u7801\uff1aarr.flatMap((x, i, arr) => i < arr.length - 1 && [arr[i], arr[i + 1], [arr[i] + arr[i + 1]]]).array()<\/code>\u3002<\/p>\n

\u4e0a\u9762\u7684\u793a\u4f8b\u6211\u4eec\u4f7f\u7528 flatMap()<\/code> \u5b9e\u73b0\u4e86\u6570\u7ec4\u589e\u52a0\u5143\u7d20<\/strong>\u7684\u64cd\u4f5c\uff0c\u63a5\u4e0b\u6765\u6211\u4eec\u6765\u770b\u4e00\u4e0b\u5982\u4f55\u5220\u9664\u5143\u7d20<\/strong>\u3002<\/p>\n

\u6211\u4eec\u901a\u5e38\u4f7f\u7528 filter()<\/code> \u65b9\u6cd5\u6765\u8fc7\u6ee4\u6570\u636e\uff0c\u5982 [1, 2, 3, 4].filter(x => x % 2 === 0)<\/code> \u6765\u5f97\u5230\u5076\u6570\u7ec4\u6210\u7684\u6570\u7ec4\uff0c\u800c\u4f7f\u7528 flatMap()<\/code> \u5220\u9664\u4e0d\u9700\u8981\u7684\u6570\u7ec4\u9879\uff0c\u53ea\u9700\u8981\u8fd4\u56de []<\/code> \u5373\u53ef\uff0c\u5982\uff1a[1, 2, 3, 4].flatMap(x => x % 2 === 0 ? [x] : [])<\/code>\u3002<\/p>\n

\u6700\u540e\uff0c\u8bf4\u4e00\u4e0b flatMap()<\/code> \u4e4b\u6240\u4ee5\u53eb\u8fd9\u4e2a\u540d\u5b57\uff0c\u662f\u56e0\u4e3a\u5b83\u5b9e\u9645\u4e0a\u662f\u5148\u6267\u884c\u4e86 map()<\/code> \u64cd\u4f5c\uff0c\u7136\u540e\u518d\u6267\u884c\u4e86\u6df1\u5ea6\u4e3a 1<\/code> \u7684 flat()<\/code> \u64cd\u4f5c\u3002<\/p>\n

```dataviewjs\nconst arr = [{a: 1, b: 2, c: [1, 2]}, {a: 3, b: 4, c: [3, 4]}, {a: 5, b: 6, c: [5, 6]}]\n\nconsole.log(arr.map(x => x.c).flat()) \/\/ [1, 2, 3, 4, 5, 6]\nconsole.log(arr.flatMap(x => x.c)) \/\/ [1, 2, 3, 4, 5, 6]\n<\/code><\/pre>\n

\u56db\u3001\u6570\u636e\u67e5\u8be2\u4e0e\u8fc7\u6ee4<\/h2>\n

\u5728 JavaScript \u4e2d\u6570\u636e\u6570\u636e\u67e5\u8be2\u901a\u5e38\u4f7f\u7528 find()\/findIndex()\/findLastIndex()<\/code>, includes()<\/code> \u548c indexOf()\/lastIndexOf()<\/code> \u8fd9\u51e0\u79cd\u65b9\u6cd5\uff0c\u800c\u8fc7\u6ee4\u5219\u4f7f\u7528 filter()<\/code>\u3002\u5728 DataArray \u4e2d\u652f\u6301 find()\/findIndex()<\/code>, includes()<\/code>\uff0cindexOf()<\/code> \u548c filter()<\/code> \u65b9\u6cd5\u3002<\/p>\n

1. where()\u65b9\u6cd5<\/h3>\n

\u5728 Dataview \u4e2d\u6211\u4eec\u901a\u5e38\u4f7f\u7528 where(predicate: ArrayFunc<T, boolean>): DataArray<T><\/code> \u65b9\u6cd5\u6765\u8fc7\u6ee4\u6570\u636e\uff0c\u540c\u6837\u4e5f\u53ef\u4ee5\u4f7f\u7528 filter()<\/code> \u65b9\u6cd5\uff0c\u4e24\u8005\u662f\u4e00\u6837\u7684\uff0c\u53ea\u4e0d\u8fc7\u540e\u8005\u662f JavaScript \u4e2d\u6570\u7ec4\u7684\u5e38\u7528\u65b9\u6cd5\u3002<\/p>\n

\u4e0b\u9762\u6211\u4eec\u63a5\u7740\u8bb2\u89e3 mutate()<\/code> \u65b9\u6cd5\u65f6\u4f7f\u7528\u7684\u4e66\u7c4d\u67e5\u8be2\u793a\u4f8b\uff0c\u52a0\u4e0a\u4e00\u4e2a\u6761\u4ef6\u5224\u65ad\uff1a<\/p>\n

```dataviewjs\ndv.table([\"File\", \"Author\", \"Book topics\", \"Genres\", \"Progress\"], dv.pages('\"10 Example Data\/books\"')\n    .where(b => b.author === \"Dora D\" && b.genres.includes(\"Dystopia\"))\n    .mutate(b => b.percent = (b.pagesRead \/ b.totalPages * 100).toFixed(2) + \"%\")\n    .map(b => [b.file.link, b.author, b.booktopics, b.genres, b.percent]))\n<\/code><\/pre>\n

\u7ed3\u679c\uff1a
\n \"\"<\/p>\n

\n [!warning] \u9700\u8981\u6ce8\u610f\u7684\u662f\u4f7f\u7528where()\u65b9\u6cd5\u67e5\u8be2\u6570\u636e\u65f6\u53ef\u80fd\u4f1a\u4fee\u6539\u539f\u59cb\u6570\u636e\n<\/p><\/blockquote>\n

\u4e0b\u9762\u4ee5\u00a0filter()<\/code>\u00a0\u65b9\u6cd5\u6765\u4e3e\u4f8b\uff1a<\/p>\n

const arr = [1, 2, 3, 4, 5, 6]\nconst result = arr.filter((d, i, arr) => {\n    if (i < arr.length - 1) arr[i + 1] += 10\n    return d < 5\n})\nconsole.log(result, arr) \/\/ [1] (6)\u00a0[1, 12, 13, 14, 15, 16]\n\nconst arr2 = [1, 2, 3, 4, 5, 6]\nconst result2 = arr2.filter((d, i, arr) => {\n    arr.push(3)\n    return d < 4\n})\nconsole.log(result2, arr2) \/\/ [1, 2, 3] (12)\u00a0[1, 2, 3, 4, 5, 6, 3, 3, 3, 3, 3, 3]\n\nconst arr3 = [1, 2, 3, 4, 5, 6]\nconst result3 = arr3.filter((d, i, arr) => {\n    arr.pop()\n    return d < 5\n})\nconsole.log(result3, arr3) \/\/ [1, 2, 3] (3)\u00a0[1, 2, 3]\n<\/code><\/pre>\n

\u5bf9 arr<\/code> \u7684\u8fc7\u6ee4\u4e2d\u6211\u4eec\u5c06\u5f53\u524d\u904d\u5386\u7684\u6570\u636e\u9879\u7684\u4e0b\u4e00\u9879\u6267\u884c\u4e86\u52a0 10<\/code> \u64cd\u4f5c\uff0c\u5bfc\u81f4\u7b2c 2 \u6b21\u6267\u884c\u65f6\u5176\u503c\u4e3a 12<\/code>\uff0c\u4f9d\u6b21\u7c7b\u63a8\uff0c\u6700\u7ec8\u53ea\u6709\u7b2c\u4e00\u6b21\u6267\u884c\u65f6\u6ee1\u8db3\u8fc7\u6ee4\u6761\u4ef6\u3002<\/p>\n

\u5bf9 arr2<\/code> \u7684\u8fc7\u6ee4\u4e2d\u6211\u4eec\u6bcf\u6267\u884c\u4e00\u6b21\u8fc7\u6ee4\u51fd\u6570\u5c31\u5728\u6570\u7ec4\u7684\u540e\u9762\u52a0\u4e0a\u6570\u5b57 3<\/code>\uff0c\u89c2\u5bdf\u7ed3\u679c\u5e76\u6ca1\u6709\u5bf9\u6269\u5145\u540e\u7684\u6570\u636e\u9879\u8fdb\u884c\u904d\u5386\uff0c\u56e0\u4e3a\u8fd9\u4f1a\u8fdb\u5165\u4e00\u4e2a\u6b7b\u5faa\u73af\u3002<\/p>\n

\u5bf9 arr3<\/code> \u7684\u8fc7\u6ee4\u4e2d\u6211\u4eec\u6bcf\u6267\u884c\u4e00\u6b21\u8fc7\u6ee4\u51fd\u6570\u5c31\u4ece\u6570\u7ec4\u5c3e\u90e8\u79fb\u51fa\u4e00\u4e2a\u5143\u7d20\uff0c\u8fd9\u6700\u7ec8\u5bfc\u81f4\u6267\u884c 3 \u6b21\u540e\u5df2\u518d\u5143\u5c0f\u4e8e 5<\/code> \u7684\u5143\u7d20\u4e86\uff0c\u56e0\u4e3a 4<\/code> \u5df2\u7ecf\u79fb\u51fa\u6570\u7ec4\u4e86\u3002<\/p>\n

2. find()\u548cfindIndex()\u65b9\u6cd5<\/h3>\n

find(pred: ArrayFunc<T, boolean>): T | undefined<\/code> \u65b9\u6cd5\u8fd4\u56de\u6570\u7ec4\u4e2d\u6ee1\u8db3\u63d0\u4f9b\u7684\u6d4b\u8bd5\u51fd\u6570\u7684\u7b2c\u4e00\u4e2a\u5143\u7d20\u7684\u503c\uff0c\u5426\u8005\u8fd4\u56de undefined<\/code>\u3002\u5982\u679c\u9700\u8981\u67e5\u8be2\u67d0\u4e2a\u503c\u7684\u7d22\u5f15\uff0c\u5219\u4f7f\u7528 findIndex(pred: ArrayFunc<T, boolean>, fromIndex?: number): number<\/code> \u65b9\u6cd5\u3002<\/p>\n

\u4e0b\u9762\u6211\u4eec\u901a\u8fc7\u8fd9\u4e24\u4e2a\u65b9\u6cd5\u6765\u627e\u51fa 6:00-6:30 \u7b2c\u4e00\u6b21\u65e9\u8d77\u7684\u65e5\u671f\u548c\u5728\u65e5\u8bb0\u4e2d\u8bb0\u5f55\u7684\u7d22\u5f15\u4f4d\u7f6e\uff0c\u9700\u8981\u6ce8\u610f\u7684\u662f\u7531\u4e8e\u7b2c\u4e00\u7bc7\u65e5\u8bb0\u6ca1\u6709\u76f8\u5173\u6570\u636e\uff0c\u6240\u4ee5\u8fd9\u91cc\u7684 index<\/code> \u7ed3\u679c\u4e3a 2<\/code>\u3002<\/p>\n

```dataviewjs\nconst dt = dv.luxon.DateTime\nconst link = dv.pages('\"10 Example Data\/dailys\"').find(p => {\n    const wakeUpTime = p['wake-up'] && dt.fromFormat(p['wake-up'], 'HH:mm').startOf('minute')\n    const start = dt.fromObject({ hour: 6, minute: 0 }).startOf('minute')\n    const end = dt.fromObject({ hour: 6, minute: 30 }).startOf('minute')\n    return wakeUpTime > start && wakeUpTime < end\n}).file.link\n\nconst index = dv.pages('\"10 Example Data\/dailys\"').findIndex(p => {\n    const wakeUpTime = p['wake-up'] && dt.fromFormat(p['wake-up'], 'HH:mm').startOf('minute')\n    const start = dt.fromObject({ hour: 6, minute: 0 }).startOf('minute')\n    const end = dt.fromObject({ hour: 6, minute: 30 }).startOf('minute')\n    return wakeUpTime > start && wakeUpTime < end\n})\n\ndv.span(`\u7b2c ${index + 1} \u5929(${link})\u5f00\u59cb 6:00-6:30 \u65e9\u8d77`)\n<\/code><\/pre>\n

3. includes()\u65b9\u6cd5<\/h3>\n

includes(element: T): boolean<\/code> \u65b9\u6cd5\u7528\u4e8e\u5224\u65ad\u6570\u7ec4\u4e2d\u662f\u5426\u5305\u542b\u67d0\u4e2a\u6570\u636e\u9879\u3002<\/p>\n

\u5bf9\u4e8e\u6570\u7ec4 [1, 2, 3]<\/code> \u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 dv.array([1, 2, 3]).includes(2)<\/code> \u6765\u5224\u65ad 2<\/code> \u662f\u5426\u5728\u6570\u7ec4\u4e2d\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u5224\u65ad\u9875\u9762\u662f\u5426\u5728\u65e5\u8bb0\u76ee\u5f55\u4e2d\u7684\u793a\u4f8b\uff1a<\/p>\n

```dataviewjs\nconsole.log(dv.pages('\"10 Example Data\/dailys\"').includes(dv.page(\"2022-01-12\"))) \/\/ true\nconsole.log(dv.pages('\"10 Example Data\/dailys\"').includes(dv.page(\"2023-01-12\"))) \/\/ false\n<\/code><\/pre>\n

4. indexOf()\u65b9\u6cd5<\/h3>\n

indexOf(element: T, fromIndex?: number): number<\/code> \u65b9\u6cd5\u8fd4\u56de\u6570\u7ec4\u4e2d\u7b2c fromIndex<\/code> \u6b21\u51fa\u73b0\u7ed9\u5b9a\u5143\u7d20\u7684\u4e0b\u6807\uff0c\u5982\u679c\u4e0d\u5b58\u5728\u5219\u8fd4\u56de -1<\/code>\u3002\u8fd9\u4e2a\u65b9\u6cd5\u7684\u4f7f\u7528\u573a\u666f\u76ee\u524d\u4f5c\u8005\u80fd\u60f3\u7684\u662f\u591a\u4e2a\u540c\u540d\u6587\u4ef6\uff08\u5982\u672a\u547d\u540d\u7684\uff09\u7684\u67e5\u627e\uff0c\u4e0d\u8fc7\u8fd9\u91cc\u4e0d\u6253\u7b97\u8fd9\u4e2a\u4f5c\u4e3a\u793a\u4f8b\uff0c\u800c\u662f\u4ee5\u666e\u901a\u7684\u6570\u5b57\u6570\u7ec4\u66f4\u65b9\u4fbf\u76f4\u767d\u3002<\/p>\n

```dataviewjs\nconst data = dv.array([1, 2, 3, 2, 45, 23, 2, 32, 43242, 5435, 2, 23])\nconsole.log(data.indexOf(2)) \/\/ 1\nconsole.log(data.indexOf(2, data.length - 1)) \/\/ -1\nconsole.log(data.indexOf(2, 4)) \/\/ 6\n<\/code><\/pre>\n

\u4e94\u3001\u6d4b\u8bd5\u5224\u65ad<\/h2>\n

\u5728 JavaScript \u4e2d\u53ef\u4ee5\u901a\u8fc7\u6570\u7ec4\u7684 every()<\/code> \u65b9\u6cd5\u6d4b\u8bd5\u4e00\u4e2a\u6570\u7ec4\u5185\u7684\u6240\u6709\u5143\u7d20\u662f\u5426\u90fd\u80fd\u901a\u8fc7\u6307\u5b9a\u51fd\u6570\u7684\u6d4b\u8bd5\uff0c\u4f7f\u7528 some()<\/code> \u65b9\u6cd5\u6d4b\u8bd5\u6570\u7ec4\u4e2d\u662f\u5426\u81f3\u5c11\u6709\u4e00\u4e2a\u5143\u7d20\u901a\u8fc7\u4e86\u7531\u63d0\u4f9b\u7684\u51fd\u6570\u5b9e\u73b0\u7684\u6d4b\u8bd5\u3002\u5982\u679c\u5728\u6570\u7ec4\u4e2d\u627e\u5230\u4e00\u4e2a\u5143\u7d20\u4f7f\u5f97\u63d0\u4f9b\u7684\u51fd\u6570\u8fd4\u56de true<\/code>\uff0c\u5219\u8fd4\u56de true<\/code>\uff1b\u5426\u5219\u8fd4\u56de false<\/code>\u3002\u800c DataArray \u540c\u6837\u4e5f\u63d0\u4f9b\u4e86\u8fd9\u4e24\u4e2a\u65b9\u6cd5\uff0c\u540c\u65f6\u8fd8\u63d0\u4f9b\u4e86\u4e00\u4e2a\u548c every()<\/code> \u76f8\u53cd\u7684 none()<\/code> \u65b9\u6cd5\u3002<\/p>\n

```dataviewjs\nconst data = dv.array([11, 20, 23, 43, 123, 13, 55])\nconsole.log(data.every(item => item > 10)) \/\/ true\nconsole.log(data.none(item => item > 10)) \/\/ false\nconsole.log(data.some(item => item > 100)) \/\/ true\n<\/code><\/pre>\n

\u516d\u3001\u5206\u7ec4\u4e0e\u5c55\u5f00\u64cd\u4f5c<\/h2>\n

\u5728 DQL \u67e5\u8be2\u8bed\u53e5\u4e2d\u6211\u4eec\u4f7f\u7528 GROUP BY<\/code> \u6765\u5c06\u6570\u636e\u6309\u6307\u5b9a\u7684\u5b57\u6bb5\u8fdb\u884c\u5206\u7ec4\uff0c\u800c\u4f7f\u7528 FLATTEN<\/code> \u6765\u5bf9\u67e5\u8be2\u7ed3\u679c\u8fdb\u884c\u5c55\u5f00\u3002\u4f46\u662f\u5728\u4f7f\u7528 API \u65f6\u6211\u4eec\u9700\u8981\u81ea\u5df1\u6765\u89e3\u6790\u5206\u7ec4\u540e\u7684\u6570\u636e\uff0c\u53ef\u81ea\u5b9a\u4e49\u6e32\u67d3\uff0c\u867d\u7136\u5f88\u7075\u6d3b\uff0c\u4f46\u662f\u4e5f\u589e\u52a0\u4e86\u6210\u672c\u3002<\/p>\n

DataArray \u63a5\u53e3\u63d0\u4f9b\u4e86 groupBy()<\/code> \u65b9\u6cd5\u6765\u5bf9\u6570\u636e\u8fdb\u884c\u5206\u7ec4\uff0cexpan()<\/code> \u65b9\u6cd5\u6765\u5c55\u5f00\u6570\u636e\u3002<\/p>\n

1. groupBy()\u65b9\u6cd5<\/h3>\n

\u65b9\u6cd5\u7684\u7b7e\u540d\u4e3a\uff1a groupBy<U>(key: ArrayFunc<T, U>, comparator?: ArrayComparator<U>): DataArray<{ key: U; rows: DataArray<T> }><\/code>\uff0c\u7b2c\u4e00\u4e2a\u53c2\u6570\u4e3a\u4e00\u4e2a\u51fd\u6570\uff0c\u4e00\u822c\u8fd4\u56de\u5b57\u6bb5\u540d\u79f0\uff0c\u540e\u7eed\u4f1a\u4ecb\u7ecd\u5176\u5b83\u7528\u6cd5\u3002\u7b2c\u4e8c\u4e2a\u53c2\u6570\u4e3a\u4e00\u4e2a\u6bd4\u8f83\u51fd\u6570\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u6309\u5347\u5e8f\u6392\u5e8f\u3002<\/p>\n

groupBy()<\/code> \u65b9\u6cd5\u8c03\u7528\u540e\u8fd4\u56de\u4e00\u4e2a\u7ed3\u679c\u6570\u7ec4\uff0c\u6570\u7ec4\u9879\u4e3a\u4e00\u4e2a\u5bf9\u8c61\uff0c\u5176\u4e2d key<\/code> \u5c5e\u6027\u8868\u793a\u5206\u7ec4\u7684\u540d\u79f0\uff0crows<\/code> \u8868\u793a\u5206\u7ec4\u7684\u6570\u636e\u3002<\/p>\n

\u4e3a\u4e86\u65b9\u4fbf\u7406\u89e3\uff0c\u63a5\u4e0b\u6765\u6211\u4eec\u5c06\u91c7\u7528 DQL \u548c API \u5bf9\u6bd4\u7684\u65b9\u5f0f\u6765\u4e3e\u4f8b\u3002<\/p>\n

\u793a\u4f8b\u4e00\uff1a\u4e00\u5bf9\u591a\u5206\u7ec4<\/strong>
\n\u4e0b\u9762\u6211\u4eec\u6765\u67e5\u8be2\u4e66\u7c4d\u5e76\u6309\u4f5c\u8005\u8fdb\u884c\u5206\u7ec4\u3002\u8fd9\u4e2a\u793a\u4f8b\u4e2d\u4e00\u4e2a\u4f5c\u8005\u5bf9\u5e94\u591a\u672c\u4e66\u7c4d\uff0c\u56e0\u6b64\u6211\u4eec\u9700\u8981\u5c06\u5206\u7ec4\u540e\u7684\u6570\u636e\u00a0rows<\/code>\u00a0\u8fdb\u884c\u5c55\u5f00\u3002<\/p>\n

```dataview\nTABLE rows.file.link AS \u4e66\u7c4d\nFROM \"10 Example Data\/books\"\nGROUP BY author AS \u4f5c\u8005\n\n```dataviewjs\ndv.table(['\u4f5c\u8005', '\u4e66\u7c4d'], dv.pages('"10 Example Data\/books"')\n    .groupBy((p) => p['author'])\n    .flatMap(p => {\n        const result = []\n        if (p.rows.length > 1) {\n            p.rows.forEach((r, i) => {\n                if (i > 0) {\n                    result.push(['', r])\n                } else {\n                    result.push([p.key, r])\n                }\n            })\n        } else {\n            result.push([p.key, p.rows.first()])\n        }\n        return result\n    })\n    .map(r => {\n       return [r[0], r[1].file.link]\n    }))\n<\/code><\/pre>\n\n\u7ed3\u679c\uff1a\n<img src="https:\/\/ax6s.yidacp.com:1018\/i\/2025\/02\/01\/679dd664a13d7.webp" alt="" \/>\n\n<strong>\u793a\u4f8b\u4e8c\uff1a\u591a\u5bf9\u591a\u5206\u7ec4<\/strong>\n\u540c\u6837\u662f\u67e5\u8be2\u4e66\u7c4d\u4fe1\u606f\uff0c\u8fd9\u6b21\u6211\u4eec\u67e5\u8be2\u4e66\u7c4d\u7684\u5206\u7c7b\u4fe1\u606f\u3002\u8fd9\u662f\u4e00\u4e2a\u591a\u5bf9\u591a\u7684\u5173\u7cfb\uff0c\u4e00\u672c\u4e66\u53ef\u4ee5\u5f52\u4e3a\u591a\u79cd\u7c7b\u578b\uff0c\u800c\u4e00\u4e2a\u7c7b\u578b\u4e5f\u53ef\u4ee5\u5305\u542b\u591a\u672c\u4e66\u7c4d\u3002\n\n\u5728\u4f7f\u7528 DQL \u67e5\u8be2\u8bed\u8a00\u65f6\uff0c\u9700\u8981\u6ce8\u610f\u4e00\u70b9\uff0c\u6211\u4eec\u4f7f\u7528\u4e86 <code>FLATTEN<\/code> \u8bed\u53e5\u6765\u5c55\u5f00\u5206\u7c7b\uff0c\u8ba9\u6bcf\u4e00\u4e2a\u5206\u7c7b\u5bf9\u5e94\u4e00\u672c\u4e66\u7c4d\uff0c\u4e0d\u7136\u5c31\u4f1a\u663e\u793a\u6210\u591a\u4e2a\u5206\u7c7b\u5bf9\u5e94\u4e00\u672c\u4e66\u7c4d\uff0c\u8fd9\u663e\u7136\u4e0d\u7b26\u5408\u7ed3\u679c\u3002\n\n\u5728\u4f7f\u7528 API \u5904\u7406\u8fd9\u79cd\u591a\u5bf9\u591a\u5206\u7ec4\u65f6\uff0c\u6211\u4eec\u5c31\u9700\u8981\u5206\u522b\u5bf9 <code>key<\/code> \u548c <code>rows<\/code> \u8fdb\u884c\u904d\u5386\u5c55\u5f00\u624d\u80fd\u5f97\u5230\u548c DQL \u67e5\u8be2<del>\u7c7b\u4f3c<\/del>\u7684\u7ed3\u679c\u3002\n\n<pre><code class="language-yaml line-numbers">```dataview\nTABLE rows.file.link AS \u4e66\u7c4d\nFROM \"10 Example Data\/books\"\nFLATTEN genres\nGROUP BY genres AS \u7c7b\u522b\n\n```dataviewjs\ndv.table(['\u7c7b\u522b', '\u4e66\u7c4d'], dv.pages('"10 Example Data\/books"')\n    .groupBy((p) => p['genres'])\n    .flatMap(p => {\n        const result = []\n\n        if (p.rows.length > 1) {\n            p.rows.forEach((r, i) => {\n                if (i > 0) {\n                    if (Array.isArray(p.key)) {\n                        p.key.flatMap(k => {\n                            result.push([k, r])\n                        })\n                    } else {\n                        result.push([p.key, r])\n                    }\n                } else {\n                    if (Array.isArray(p.key)) {\n                        p.key.flatMap(k => {\n                            result.push([k, r])\n                        })\n                    } else {\n                        result.push([p.key, r])\n                    }\n                }\n            })\n        } else {\n            if (Array.isArray(p.key)) {\n                p.key.flatMap(k => {\n                    result.push([k, p.rows.first()])\n                })\n            } else {\n                result.push([p.key, p.rows.first()])\n            }\n        }\n\n        return result\n    })\n    .sort(p => p[1].file.name)\n    .sort(p => p[0])\n    .flatMap((r, i, arr) => {\n        if (!r) return []\n\n        const result = []\n        const key = r[0]\n\n        for (j = i; j < arr.length; j++) {\n            if (i === j) {\n                let exist = false\n                \/\/ \u5982\u679c\u5df2\u7ecf\u5b58\u5728\u5c31\u4e0d\u518d\u6dfb\u52a0\n                for (let k = j - 1; k > 0; k--) {\n                    if (key === arr[k][0]) {\n                        exist = true\n                        break\n                    }\n                }\n\n                if (!exist) {\n                    result.push(r)\n                } else {\n                    result.push(['', arr[j][1]])\n                }\n            } else {\n                if (arr[j][0] === key) {\n                    result.push(['', arr[j][1]])\n                    arr.splice(j, 1)\n                }\n            }\n        }\n        return result\n    })\n    .map(r => {\n       return [r[0], r[1].file.link]\n    }))\n<\/code><\/pre>\n\n\u7ed3\u679c\uff1a\n  <img src="https:\/\/ax6s.yidacp.com:1018\/i\/2025\/02\/01\/679dd6a0be41e.webp" alt="" \/>\n\n\u4e0a\u8ff0\u4ee3\u7801\u867d\u7136\u6211\u4eec\u5b9e\u73b0\u4e86\u7c7b\u4f3c\u7684\u7ed3\u679c\uff0c\u4f46\u662f\u89c2\u5bdf\u7ed3\u679c\u4f1a\u53d1\u73b0\u6211\u4eec\u4e22\u5931\u4e86\u5206\u7ec4\u4fe1\u606f\uff1a\u539f\u6570\u636e\u6709 8 \u4e2a\u5206\u7ec4\uff0c\u6211\u4eec\u7684\u7ed3\u679c\u4e3a 13 \u4e2a\u5206\u7ec4\u3002\u4ee3\u7801\u4e2d\uff0c\u901a\u8fc7\u4e24\u4e2a <code>sort()<\/code> \u65b9\u6cd5\u5206\u522b\u6309\u5206\u7ec4\u5206\u7c7b\u540d\u548c\u6587\u4ef6\u540d\u8fdb\u884c\u4e86\u6392\u5e8f\uff1b\u901a\u8fc7\u4e24\u4e2a <code>flatMap()<\/code> \u65b9\u6cd5\u5206\u522b\u5904\u7406\u4e86\u6587\u6863\u540d\u79f0\u7684\u5c55\u5f00\u548c\u5206\u7c7b\u540c\u540d\u7684\u7a7a\u767d\u663e\u793a\u3002\n\n<strong>\u793a\u4f8b\u4e09\uff1a\u6839\u636e\u8ba1\u7b97\u7ed3\u679c\u5206\u7ec4<\/strong>\n\u4e0b\u9762\u8fd9\u4e2a\u793a\u4f8b\u6211\u4eec\u4e0d\u8fd4\u56de\u5b57\u6bb5\u540d\uff0c\u800c\u662f\u8fd4\u56de\u4e00\u4e2a\u6839\u636e\u6761\u4ef6\u5224\u65ad\u81ea\u5b9a\u4e49\u7684\u540d\u79f0\u3002\n\n<pre><code class="language-yaml line-numbers">```dataview\nLIST rows.file.link\nFROM \"10 Example Data\/assignments\"\nGROUP BY choice(due < date(\"2022-05-12\"), \"\u5df2\u8fc7\u671f\", \"\u8fd8\u6709\u673a\u4f1a\")\n\n```dataviewjs\ndv.list(dv.pages('"10 Example Data\/assignments"')\n    .groupBy(p => {\n        if (p.due < dv.date("2022-05-12")) {\n            return "\u5df2\u8fc7\u671f"\n        }\n        return "\u8fd8\u6709\u673a\u4f1a"\n    })\n    .flatMap(g => {\n        return [g.key, g.rows.map(r => r.file.link)]\n    }))\n<\/code><\/pre>\n\n\u7ed3\u679c\uff1a\n<img src="https:\/\/ax6s.yidacp.com:1018\/i\/2025\/02\/01\/679dd71794771.webp" alt="" \/>\n\u4ece\u7ed3\u679c\u6765\u770b\u8fd8\u662f\u6709\u7ec6\u5fae\u5dee\u522b\u7684\uff0c\u5de6\u8fb9\u5206\u7ec4\u540d\u548c\u6570\u636e\u662f\u653e\u7f6e\u5728\u4e00\u4e2a\u00a0<code><li><\/code>\u00a0\u6807\u7b7e\u4e2d\uff0c\u800c\u53f3\u8fb9\u5219\u662f\u5c06\u5206\u7ec4\u540d\u548c\u6570\u636e\u5355\u72ec\u653e\u7f6e\u5728\u4e00\u4e2a\u00a0<code><li><\/code>\u00a0\u6807\u7b7e\u4e2d\u3002\n\n<h3>2. expand()\u65b9\u6cd5<\/h3>\n\n<code>expand(key: string): DataArray<any><\/code> \u65b9\u6cd5\u7684\u4f5c\u7528\u4e0d\u540c\u4e8e <code>FLATTEN<\/code> \u8bed\u53e5\uff0c\u5b83\u53ef\u4ee5\u7528\u4e8e\u5217\u8868\u548c\u4efb\u52a1\u7684\u5c55\u5f00\uff0c\u9700\u8981\u6307\u5b9a <code>key<\/code> \u4e3a <code>children<\/code> \u6216\u8005 <code>subtasks<\/code>\uff0c\u4f46\u662f\u7ed3\u679c\u4e0d\u80fd\u4fdd\u8bc1\u662f\u6309\u539f\u6765\u7684\u987a\u5e8f\u8f93\u51fa\u3002\n\n\u8fd9\u4e2a\u65b9\u6cd5\u5728 Dataview Example Valut \u793a\u4f8b\u5e93\u4e5f\u6ca1\u6709\u627e\u5230\u76f8\u5e94\u7684\u793a\u4f8b\uff0c\u8bf4\u660e\u5176\u9002\u7528\u8303\u56f4\u5f88\u5c0f\uff0c\u5f88\u51b7\u95e8\u3002\u4f5c\u8005\u672c\u4ee5\u4e3a\u80fd\u591f\u5b9e\u73b0\u5c06\u5d4c\u5957\u7684\u4efb\u52a1\u5c55\u5f00\uff0c\u7136\u800c\u5374...\n\n<pre><code class="language-yaml line-numbers">- [ ] 1\n- [ ] 2\n\u00a0 \u00a0 - [ ] 3\n\u00a0 \u00a0 - [ ] 4\n\u00a0 \u00a0 - [ ] 5\n\u00a0 \u00a0 \u00a0 \u00a0 - [ ] 6\n\n```dataviewjs\ndv.list(dv.current().file.tasks.expand('subtasks').map(t => t.text))\ndv.taskList(dv.current().file.tasks.expand('subtasks'))\n\n<\/code><\/pre>\n

\u7ed3\u679c\uff1a
\n \"\"<\/p>\n

\u4e03\u3001\u5176\u4ed6\u65b9\u6cd5<\/h2>\n

sort()<\/code>\u00a0\u65b9\u6cd5\u6709\u5728\u524d\u9762\u7684\u793a\u4f8b\u4e2d\u5e94\u7528\u5230\uff0c\u5269\u4e0b\u7684\u90fd\u6bd4\u8f83\u7b80\u5355\uff0c\u76f4\u63a5\u4e0a\u793a\u4f8b\uff1a<\/p>\n

```dataviewjs\nconst arr = dv.array([1, 2, 3, 4, 2, 1, 23, 12])\nconsole.log(arr.distinct().array()) \/\/ [1, 2, 3, 4, 12, 23]\nconsole.log(arr.join('#')) \/\/ 1#2#3#4#2#1#23#12\nconsole.log(arr.limit(2).array()) \/\/ [1, 2]\nconsole.log(arr.slice(0, 3).array()) \/\/ [1, 2, 3]\nconsole.log(arr.concat(dv.array([5, 6, 7, 8])).array()) \/\/ [1, 2, 3, 4, 2, 1, 23, 12, 5, 6, 7, 8]\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"
\u8fd9\u7bc7\u6587\u7ae0\u662f Obsidian Dataview \u7cfb\u5217<\/a> \u7cfb\u5217 15 \u7bc7\u6587\u7ae0\u4e2d\u7684\u7b2c 9 \u7bc7<\/div>

DataArray \u63a5\u53e3\u662f Dataview \u63d0\u4f9b\u7684\u5217\u8868\u6570\u636e\u64cd\u4f5c\u7684\u62bd\u8c61\uff0c\u5b83\u662f\u5bf9 JavaScript \u6570\u7ec4\u64cd\u4f5c\u7684\u6269\u5c55\u548c\u57fa\u4e8e Dataview \u73af\u5883\u7684\u672c\u5730\u5316\u3002\u6211\u4eec\u53ef\u8fc7 dv.array() \u5c06\u4e00\u4e2a\u666e\u901a\u7684\u6570\u7ec4\u8f6c\u6362\u6210 DataArray \u7c7b\u578b\uff0c\u4e5f\u53ef\u4ee5\u53cd\u5411\u64cd\u4f5c\u5c06\u5176\u8f6c\u6362\u6210\u666e\u901a\u7684 JavaScript \u6570\u7ec4\uff0c\u6bd4\u5982\uff1adv.list(dv.current()).array()\u3002 \u4e0b\u9762\u662f\u5b98\u65b9\u63d0\u4f9b\u7684 DataArray \u63a5\u53e3\u5b9a\u4e49\uff0c\u4e3a\u4e86\u7b80\u5c11\u884c\u6570\uff0c\u5220\u9664\u4e86\u6240\u6709\u6ce8\u91ca\uff1a export type ArrayFunc<T, O> = (elem: T, index: number, arr: T[]) => […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[7],"tags":[199],"series":[201],"class_list":["post-812","post","type-post","status-publish","format-standard","hentry","category-skills","tag-obsidian","series-obsidian-dataview"],"yoast_head":"\nObsidian\u63d2\u4ef6Dataview \u2014\u2014 DataArray\u63a5\u53e3\u4ecb\u7ecd\uff08\u4e5d\uff09 - \u6ce2\u6bd4AI<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/yanghaixiong.com\/blog\/skills\/812\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Obsidian\u63d2\u4ef6Dataview \u2014\u2014 DataArray\u63a5\u53e3\u4ecb\u7ecd\uff08\u4e5d\uff09\" \/>\n<meta property=\"og:description\" content=\"DataArray \u63a5\u53e3\u662f Dataview \u63d0\u4f9b\u7684\u5217\u8868\u6570\u636e\u64cd\u4f5c\u7684\u62bd\u8c61\uff0c\u5b83\u662f\u5bf9 JavaScript \u6570\u7ec4\u64cd\u4f5c\u7684\u6269\u5c55\u548c\u57fa\u4e8e Dataview \u73af\u5883\u7684\u672c\u5730\u5316\u3002\u6211\u4eec\u53ef\u8fc7 dv.array() \u5c06\u4e00\u4e2a\u666e\u901a\u7684\u6570\u7ec4\u8f6c\u6362\u6210 DataArray \u7c7b\u578b\uff0c\u4e5f\u53ef\u4ee5\u53cd\u5411\u64cd\u4f5c\u5c06\u5176\u8f6c\u6362\u6210\u666e\u901a\u7684 JavaScript \u6570\u7ec4\uff0c\u6bd4\u5982\uff1adv.list(dv.current()).array()\u3002 \u4e0b\u9762\u662f\u5b98\u65b9\u63d0\u4f9b\u7684 DataArray \u63a5\u53e3\u5b9a\u4e49\uff0c\u4e3a\u4e86\u7b80\u5c11\u884c\u6570\uff0c\u5220\u9664\u4e86\u6240\u6709\u6ce8\u91ca\uff1a export type ArrayFunc<T, O> = (elem: T, index: number, arr: T[]) => […]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/yanghaixiong.com\/blog\/skills\/812\/\" \/>\n<meta property=\"og:site_name\" content=\"\u6ce2\u6bd4AI\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/profile.php?id=61558625288156\" \/>\n<meta property=\"article:published_time\" content=\"2025-02-06T20:03:41+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ax6s.yidacp.com:1018\/i\/2025\/02\/01\/679dd335754b6.webp\" \/>\n<meta name=\"author\" content=\"\u6ce2\u6bd4AI\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u6ce2\u6bd4AI\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/yanghaixiong.com\/blog\/skills\/812\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/yanghaixiong.com\/blog\/skills\/812\/\"},\"author\":{\"name\":\"\u6ce2\u6bd4AI\",\"@id\":\"https:\/\/yanghaixiong.com\/#\/schema\/person\/b2e169fa0bfa546c7cc66d799c5eee17\"},\"headline\":\"Obsidian\u63d2\u4ef6Dataview \u2014\u2014 DataArray\u63a5\u53e3\u4ecb\u7ecd\uff08\u4e5d\uff09\",\"datePublished\":\"2025-02-06T20:03:41+00:00\",\"dateModified\":\"2025-02-06T20:03:41+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/yanghaixiong.com\/blog\/skills\/812\/\"},\"wordCount\":35,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/yanghaixiong.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/yanghaixiong.com\/blog\/skills\/812\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/ax6s.yidacp.com:1018\/i\/2025\/02\/01\/679dd335754b6.webp\",\"keywords\":[\"Obsidian\"],\"articleSection\":[\"\u5b9e\u7528\u6280\u5de7\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/yanghaixiong.com\/blog\/skills\/812\/#respond\"]}],\"copyrightYear\":\"2025\",\"copyrightHolder\":{\"@id\":\"https:\/\/yanghaixiong.com\/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/yanghaixiong.com\/blog\/skills\/812\/\",\"url\":\"https:\/\/yanghaixiong.com\/blog\/skills\/812\/\",\"name\":\"Obsidian\u63d2\u4ef6Dataview \u2014\u2014 DataArray\u63a5\u53e3\u4ecb\u7ecd\uff08\u4e5d\uff09 - \u6ce2\u6bd4AI\",\"isPartOf\":{\"@id\":\"https:\/\/yanghaixiong.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/yanghaixiong.com\/blog\/skills\/812\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/yanghaixiong.com\/blog\/skills\/812\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/ax6s.yidacp.com:1018\/i\/2025\/02\/01\/679dd335754b6.webp\",\"datePublished\":\"2025-02-06T20:03:41+00:00\",\"dateModified\":\"2025-02-06T20:03:41+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/yanghaixiong.com\/blog\/skills\/812\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/yanghaixiong.com\/blog\/skills\/812\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/yanghaixiong.com\/blog\/skills\/812\/#primaryimage\",\"url\":\"https:\/\/ax6s.yidacp.com:1018\/i\/2025\/02\/01\/679dd335754b6.webp\",\"contentUrl\":\"https:\/\/ax6s.yidacp.com:1018\/i\/2025\/02\/01\/679dd335754b6.webp\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/yanghaixiong.com\/blog\/skills\/812\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/yanghaixiong.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Obsidian\u63d2\u4ef6Dataview \u2014\u2014 DataArray\u63a5\u53e3\u4ecb\u7ecd\uff08\u4e5d\uff09\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/yanghaixiong.com\/#website\",\"url\":\"https:\/\/yanghaixiong.com\/\",\"name\":\"\u6ce2\u6bd4AI\",\"description\":\"\u8de8\u5883\u7535\u5546B2C\u7ecf\u9a8c\u8bb0\u5f55\u3001\u4ea4\u6d41\u4e0e\u5206\u4eab\",\"publisher\":{\"@id\":\"https:\/\/yanghaixiong.com\/#organization\"},\"alternateName\":\"\u5927\u96c4B2C\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/yanghaixiong.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":[\"Organization\",\"Place\"],\"@id\":\"https:\/\/yanghaixiong.com\/#organization\",\"name\":\"\u6ce2\u6bd4AI\",\"alternateName\":\"\u6768\u6d77\u96c4\",\"url\":\"https:\/\/yanghaixiong.com\/\",\"logo\":{\"@id\":\"https:\/\/yanghaixiong.com\/blog\/skills\/812\/#local-main-organization-logo\"},\"image\":{\"@id\":\"https:\/\/yanghaixiong.com\/blog\/skills\/812\/#local-main-organization-logo\"},\"sameAs\":[\"https:\/\/www.facebook.com\/profile.php?id=61558625288156\"],\"description\":\"\u8de8\u5883\u7535\u5546B2C\u7ecf\u9a8c\u8bb0\u5f55\u3001\u4ea4\u6d41\u4e0e\u5206\u4eab\",\"telephone\":[],\"openingHoursSpecification\":[{\"@type\":\"OpeningHoursSpecification\",\"dayOfWeek\":[\"Monday\",\"Tuesday\",\"Wednesday\",\"Thursday\",\"Friday\",\"Saturday\",\"Sunday\"],\"opens\":\"09:00\",\"closes\":\"17:00\"}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/yanghaixiong.com\/#\/schema\/person\/b2e169fa0bfa546c7cc66d799c5eee17\",\"name\":\"\u6ce2\u6bd4AI\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/yanghaixiong.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/a71b573316787cebbf7f3c2c742eab21?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/a71b573316787cebbf7f3c2c742eab21?s=96&d=mm&r=g\",\"caption\":\"\u6ce2\u6bd4AI\"},\"sameAs\":[\"https:\/\/yanghaixiong.com\"],\"url\":\"https:\/\/yanghaixiong.com\/blog\/author\/yanghxyidacp-com\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/yanghaixiong.com\/blog\/skills\/812\/#local-main-organization-logo\",\"url\":\"https:\/\/yanghaixiong.com\/wp-content\/uploads\/2024\/08\/screenshot.png\",\"contentUrl\":\"https:\/\/yanghaixiong.com\/wp-content\/uploads\/2024\/08\/screenshot.png\",\"width\":1200,\"height\":900,\"caption\":\"\u6ce2\u6bd4AI\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Obsidian\u63d2\u4ef6Dataview \u2014\u2014 DataArray\u63a5\u53e3\u4ecb\u7ecd\uff08\u4e5d\uff09 - \u6ce2\u6bd4AI","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/yanghaixiong.com\/blog\/skills\/812\/","og_locale":"zh_CN","og_type":"article","og_title":"Obsidian\u63d2\u4ef6Dataview \u2014\u2014 DataArray\u63a5\u53e3\u4ecb\u7ecd\uff08\u4e5d\uff09","og_description":"DataArray \u63a5\u53e3\u662f Dataview \u63d0\u4f9b\u7684\u5217\u8868\u6570\u636e\u64cd\u4f5c\u7684\u62bd\u8c61\uff0c\u5b83\u662f\u5bf9 JavaScript \u6570\u7ec4\u64cd\u4f5c\u7684\u6269\u5c55\u548c\u57fa\u4e8e Dataview \u73af\u5883\u7684\u672c\u5730\u5316\u3002\u6211\u4eec\u53ef\u8fc7 dv.array() \u5c06\u4e00\u4e2a\u666e\u901a\u7684\u6570\u7ec4\u8f6c\u6362\u6210 DataArray \u7c7b\u578b\uff0c\u4e5f\u53ef\u4ee5\u53cd\u5411\u64cd\u4f5c\u5c06\u5176\u8f6c\u6362\u6210\u666e\u901a\u7684 JavaScript \u6570\u7ec4\uff0c\u6bd4\u5982\uff1adv.list(dv.current()).array()\u3002 \u4e0b\u9762\u662f\u5b98\u65b9\u63d0\u4f9b\u7684 DataArray \u63a5\u53e3\u5b9a\u4e49\uff0c\u4e3a\u4e86\u7b80\u5c11\u884c\u6570\uff0c\u5220\u9664\u4e86\u6240\u6709\u6ce8\u91ca\uff1a export type ArrayFunc<T, O> = (elem: T, index: number, arr: T[]) => […]","og_url":"https:\/\/yanghaixiong.com\/blog\/skills\/812\/","og_site_name":"\u6ce2\u6bd4AI","article_publisher":"https:\/\/www.facebook.com\/profile.php?id=61558625288156","article_published_time":"2025-02-06T20:03:41+00:00","og_image":[{"url":"https:\/\/ax6s.yidacp.com:1018\/i\/2025\/02\/01\/679dd335754b6.webp"}],"author":"\u6ce2\u6bd4AI","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u6ce2\u6bd4AI"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/yanghaixiong.com\/blog\/skills\/812\/#article","isPartOf":{"@id":"https:\/\/yanghaixiong.com\/blog\/skills\/812\/"},"author":{"name":"\u6ce2\u6bd4AI","@id":"https:\/\/yanghaixiong.com\/#\/schema\/person\/b2e169fa0bfa546c7cc66d799c5eee17"},"headline":"Obsidian\u63d2\u4ef6Dataview \u2014\u2014 DataArray\u63a5\u53e3\u4ecb\u7ecd\uff08\u4e5d\uff09","datePublished":"2025-02-06T20:03:41+00:00","dateModified":"2025-02-06T20:03:41+00:00","mainEntityOfPage":{"@id":"https:\/\/yanghaixiong.com\/blog\/skills\/812\/"},"wordCount":35,"commentCount":0,"publisher":{"@id":"https:\/\/yanghaixiong.com\/#organization"},"image":{"@id":"https:\/\/yanghaixiong.com\/blog\/skills\/812\/#primaryimage"},"thumbnailUrl":"https:\/\/ax6s.yidacp.com:1018\/i\/2025\/02\/01\/679dd335754b6.webp","keywords":["Obsidian"],"articleSection":["\u5b9e\u7528\u6280\u5de7"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/yanghaixiong.com\/blog\/skills\/812\/#respond"]}],"copyrightYear":"2025","copyrightHolder":{"@id":"https:\/\/yanghaixiong.com\/#organization"}},{"@type":"WebPage","@id":"https:\/\/yanghaixiong.com\/blog\/skills\/812\/","url":"https:\/\/yanghaixiong.com\/blog\/skills\/812\/","name":"Obsidian\u63d2\u4ef6Dataview \u2014\u2014 DataArray\u63a5\u53e3\u4ecb\u7ecd\uff08\u4e5d\uff09 - \u6ce2\u6bd4AI","isPartOf":{"@id":"https:\/\/yanghaixiong.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/yanghaixiong.com\/blog\/skills\/812\/#primaryimage"},"image":{"@id":"https:\/\/yanghaixiong.com\/blog\/skills\/812\/#primaryimage"},"thumbnailUrl":"https:\/\/ax6s.yidacp.com:1018\/i\/2025\/02\/01\/679dd335754b6.webp","datePublished":"2025-02-06T20:03:41+00:00","dateModified":"2025-02-06T20:03:41+00:00","breadcrumb":{"@id":"https:\/\/yanghaixiong.com\/blog\/skills\/812\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/yanghaixiong.com\/blog\/skills\/812\/"]}]},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/yanghaixiong.com\/blog\/skills\/812\/#primaryimage","url":"https:\/\/ax6s.yidacp.com:1018\/i\/2025\/02\/01\/679dd335754b6.webp","contentUrl":"https:\/\/ax6s.yidacp.com:1018\/i\/2025\/02\/01\/679dd335754b6.webp"},{"@type":"BreadcrumbList","@id":"https:\/\/yanghaixiong.com\/blog\/skills\/812\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/yanghaixiong.com\/"},{"@type":"ListItem","position":2,"name":"Obsidian\u63d2\u4ef6Dataview \u2014\u2014 DataArray\u63a5\u53e3\u4ecb\u7ecd\uff08\u4e5d\uff09"}]},{"@type":"WebSite","@id":"https:\/\/yanghaixiong.com\/#website","url":"https:\/\/yanghaixiong.com\/","name":"\u6ce2\u6bd4AI","description":"\u8de8\u5883\u7535\u5546B2C\u7ecf\u9a8c\u8bb0\u5f55\u3001\u4ea4\u6d41\u4e0e\u5206\u4eab","publisher":{"@id":"https:\/\/yanghaixiong.com\/#organization"},"alternateName":"\u5927\u96c4B2C","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/yanghaixiong.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":["Organization","Place"],"@id":"https:\/\/yanghaixiong.com\/#organization","name":"\u6ce2\u6bd4AI","alternateName":"\u6768\u6d77\u96c4","url":"https:\/\/yanghaixiong.com\/","logo":{"@id":"https:\/\/yanghaixiong.com\/blog\/skills\/812\/#local-main-organization-logo"},"image":{"@id":"https:\/\/yanghaixiong.com\/blog\/skills\/812\/#local-main-organization-logo"},"sameAs":["https:\/\/www.facebook.com\/profile.php?id=61558625288156"],"description":"\u8de8\u5883\u7535\u5546B2C\u7ecf\u9a8c\u8bb0\u5f55\u3001\u4ea4\u6d41\u4e0e\u5206\u4eab","telephone":[],"openingHoursSpecification":[{"@type":"OpeningHoursSpecification","dayOfWeek":["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],"opens":"09:00","closes":"17:00"}]},{"@type":"Person","@id":"https:\/\/yanghaixiong.com\/#\/schema\/person\/b2e169fa0bfa546c7cc66d799c5eee17","name":"\u6ce2\u6bd4AI","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/yanghaixiong.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/a71b573316787cebbf7f3c2c742eab21?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/a71b573316787cebbf7f3c2c742eab21?s=96&d=mm&r=g","caption":"\u6ce2\u6bd4AI"},"sameAs":["https:\/\/yanghaixiong.com"],"url":"https:\/\/yanghaixiong.com\/blog\/author\/yanghxyidacp-com\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/yanghaixiong.com\/blog\/skills\/812\/#local-main-organization-logo","url":"https:\/\/yanghaixiong.com\/wp-content\/uploads\/2024\/08\/screenshot.png","contentUrl":"https:\/\/yanghaixiong.com\/wp-content\/uploads\/2024\/08\/screenshot.png","width":1200,"height":900,"caption":"\u6ce2\u6bd4AI"}]}},"acf":[],"_links":{"self":[{"href":"https:\/\/yanghaixiong.com\/wp-json\/wp\/v2\/posts\/812","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yanghaixiong.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yanghaixiong.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yanghaixiong.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yanghaixiong.com\/wp-json\/wp\/v2\/comments?post=812"}],"version-history":[{"count":1,"href":"https:\/\/yanghaixiong.com\/wp-json\/wp\/v2\/posts\/812\/revisions"}],"predecessor-version":[{"id":813,"href":"https:\/\/yanghaixiong.com\/wp-json\/wp\/v2\/posts\/812\/revisions\/813"}],"wp:attachment":[{"href":"https:\/\/yanghaixiong.com\/wp-json\/wp\/v2\/media?parent=812"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yanghaixiong.com\/wp-json\/wp\/v2\/categories?post=812"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yanghaixiong.com\/wp-json\/wp\/v2\/tags?post=812"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/yanghaixiong.com\/wp-json\/wp\/v2\/series?post=812"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}