0
Search by Title
One script reply has been approved by the moderators Verified
Created by adam186 339 days ago Viewed 2410 times
0
Submitted by adam186 Deno
Verified 339 days ago
1
import { removeObjectEmptyFields } from "https://deno.land/x/windmill_helpers@v1.1.1/mod.ts";
2
import { Client } from "npm:@notionhq/client";
3

4
/**
5
 * Learn more at
6
 * https://developers.notion.com/reference/post-search
7
 */
8
type Notion = {
9
  token: string;
10
};
11
export async function main(
12
  auth: Notion,
13
  query?: string,
14
  filter?: { property: string; value: string },
15
  sort?: { timestamp: string; direction: string },
16
  start_cursor?: string,
17
  page_size?: number,
18
) {
19
  const client = new Client({ auth: auth.token });
20
  const args = removeObjectEmptyFields({
21
    query,
22
    filter,
23
    sort,
24
    start_cursor,
25
    page_size,
26
  });
27
  return await client.search(args);
28
}
29