node-notion-database
v0.0.4
Published
Node.js를 이용하여 notion database 사용하기
Downloads
6
Maintainers
Readme
node-notion-database
npm 사용:
$ npm i node-notion-database
yarn 사용:
$ yarn add node-notion-database
지원 property type
Title, Text, Checkbox, Date, Number, Select
예제(usage)
import NotionDatabase from "notionDatabase";
interface IProperties {
카운트: number;
description: string;
포스팅여부: boolean;
포스팅날짜: any;
status: any;
name: string;
id: string;
}
const notionDatabase = new NotionDatabase<IProperties>({
secretKey: "Your notion Secret Key",
databaseId: "Your notion Database Id",
});
const filter = {
and: [
{
property: "포스팅여부",
checkbox: {
equals: true,
},
},
{
property: "카운트",
number: {
greater_than_or_equal_to: 2,
},
},
],
};
const sorts = [{ property: "카운트", direction: "ascending" }];
// query all
const queyrResult = await notionDatabase.query();
console.log(queyrResult);
// query filter
const queyrFilterResult = await notionDatabase.query({ filter });
console.log(queyrFilterResult);
// query sort
const queyrSortResult = await notionDatabase.query({ sorts });
console.log(queyrSortResult);
// query filter and sort
const queyrFilterAndSortResult = await notionDatabase.query({
filter,
sorts,
});
console.log(queyrFilterAndSortResult);
//create
const createResult = await notionDatabase.create([
{ type: "title", key: "id", value: "new id" },
{ type: "text", key: "description", value: "description update" },
{ type: "text", key: "name", value: "name update" },
{ type: "checkbox", key: "포스팅여부", value: true },
{ type: "date", key: "포스팅날짜", value: "2022-09-01" },
{ type: "number", key: "카운트", value: 1163 },
{ type: "select", key: "status", value: "In" },
]);
// update
const updateResult = await notionDatabase.update({
pageId: "your page_id",
updateDatas: [
{ type: "title", key: "id", value: "id update" },
{ type: "text", key: "description", value: "description update" },
{ type: "text", key: "name", value: "name update" },
{ type: "checkbox", key: "포스팅여부", value: true },
{ type: "date", key: "포스팅날짜", value: "2022-02-01" },
{ type: "number", key: "카운트", value: 1122263 },
{ type: "select", key: "status", value: "Inaaa" },
],
});