基本的な使用方法
IDで単一のアイテムを取得:型安全性
NotCMSは取得したアイテムに対して完全な型推論を提供します:関連アイテム
複数のクエリを使用して関連アイテムを取得:次のステップ
アイテムの一覧取得
複数アイテムのクエリ方法を学ぶ
クライアントAPI
完全なクライアントAPIを探索
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Notionデータベースから個別のアイテムを取得
const [post, error] = await nc.query.blog.get('page-id-123');
if (!error) {
console.log(post.title, post.content);
}
// 単一ページ型を推論
type BlogPost = typeof nc.query.blog.$inferPage;
// 関数で使用
function processBlogPost(post: BlogPost) {
// 完全な型安全性とIDEの自動補完
console.log(post.title);
console.log(post.published);
console.log(post.author);
}
async function getPostWithAuthor(postId: string) {
// 記事を取得
const [post, postError] = await nc.query.blog.get(postId);
if (postError) throw postError;
// 著者を取得
const [author, authorError] = await nc.query.authors.get(post.properties.authors[0]);
if (authorError) throw authorError;
return {
...post,
author
};
}