1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
| const { Client } = require("@notionhq/client");
const config = require("./config.json");
const notion = new Client({ auth: config.NOTION_API_KEY });
const database_id = config.DATABASE[0].DATABASE_ID;
async function search(filter) {
const response = await notion.databases.retrieve({
database_id: database_id,
filter: filter,
});
console.log(response);
}
async function select(filter) {
const response = await notion.databases.query({
database_id: database_id,
filter: filter,
});
//console.log(response);
let data = response.results[0].properties;
console.log(data.Name.title[0].plain_text);
console.log(data.Tags.multi_select);
}
async function insert(data) {
const response = await notion.pages.create({
parent: {
database_id: database_id,
},
properties: data,
});
console.log(response);
}
let newItem = {
Name: {
type: "title",
title: [
{
type: "text",
text: {
content: "Apple",
},
}
],
},
/*
Price: {
type: "number",
number: 1.49,
},
"Last ordered": {
type: "date",
date: {
start: "2021-05-11",
},
},
*/
};
let timeFilter = {
property: "Last ordered",
date: {
past_week: {},
},
};
let filter = {
property: "Name",
text: {
contains: "pp",
},
};
//insert(newItem);
select(filter);
|