我可以使用https://api.notion.com/v1/databases/:id/query获取给定数据库的分页子列表。但是我可以在任何地方获得当前的孩子数量吗?
问问题
87 次
2 回答
1
该 API 在 API 的当前版本(Notion-Version:2021-05-13)中没有提供结果计数。
于 2021-05-27T20:36:30.807 回答
0
如果您想要数据库中的页面(子)数,假设它是javascript。
<!DOCTYPE html>
<html>
<body>
<p>Click the button to create an array, then display its length.</p>
<button onclick="myFunction()">Find Length</button>
<p id="demo"></p>
<script>
function myFunction() {
var data = {
"object": "list",
"results": [{
"object": "page",
"id": "2e01e904-febd-43a0-ad02-8eedb903a82c",
"created_time": "2020-03-17T19:10:04.968Z",
"last_edited_time": "2020-03-17T21:49:37.913Z",
"parent": {
"type": "database_id",
"database_id": "897e5a76-ae52-4b48-9fdf-e71f5945d1af"
},
"archived": false,
"properties": {
"Recipes": {
"id": "Ai`L",
"type": "relation",
"relation": [{
"id": "796659b4-a5d9-4c64-a539-06ac5292779e"
},
{
"id": "79e63318-f85a-4909-aceb-96a724d1021c"
}
]
},
"Cost of next trip": {
"id": "R}wl",
"type": "formula",
"formula": {
"type": "number",
"number": 2
}
},
"Last ordered": {
"id": "UsKi",
"type": "date",
"date": {
"start": "2020-10-07",
"end": null
}
},
"In stock": {
"id": "{>U;",
"type": "checkbox",
"checkbox": false
}
}
},
{
"object": "page",
"id": "2e01e904-febd-43a0-ad02-8eedb903a82c",
"created_time": "2020-03-17T19:10:04.968Z",
"last_edited_time": "2020-03-17T21:49:37.913Z",
"parent": {
"type": "database_id",
"database_id": "897e5a76-ae52-4b48-9fdf-e71f5945d1af"
},
"archived": false,
"properties": {
"Recipes": {
"id": "Ai`L",
"type": "relation",
"relation": [{
"id": "796659b4-a5d9-4c64-a539-06ac5292779e"
},
{
"id": "79e63318-f85a-4909-aceb-96a724d1021c"
}
]
},
"Cost of next trip": {
"id": "R}wl",
"type": "formula",
"formula": {
"type": "number",
"number": 2
}
},
"Last ordered": {
"id": "UsKi",
"type": "date",
"date": {
"start": "2020-10-07",
"end": null
}
},
"In stock": {
"id": "{>U;",
"type": "checkbox",
"checkbox": false
}
}
}
],
"has_more": false,
"next_cursor": null
}
document.getElementById("demo").innerHTML = data.results.length;
}
</script>
</body>
</html>
于 2021-05-20T17:44:59.407 回答