MMK Notion — Database Commands
Prerequisite: Read
../mmk-shared/SKILL.mdfor auth, global flags, and error handling. Parent:mmk-notion
Always use -o json when parsing results or composing with other commands.
schema — Show database property schema
mmk notion database schema --database-id <db-uuid> -o json
mmk notion database schema --database-id <db-uuid> --detect-ai --page-id <page-uuid> -o json
Required: --database-id
Optional: --detect-ai (bool), --page-id (required with --detect-ai — accepts UUID or full Notion URL), --enhanced (bool — outputs LLM-friendly schema with select options and valid filter operators)
When --detect-ai is set, output includes property-id and workflow-id values needed for the ai-summary command.
query — Query a Notion database with filters, sorts, and pagination
mmk notion database query --database-id <db-uuid> -o json
mmk notion database query --database-id <db> --filter "Status=Active" --sort "CreatedDate:desc" --limit 10 -o json
mmk notion database query --database-id <db> --filter "Status=Active" --filter "Done=false" --properties "Name,Status,Price" -o json
mmk notion database query --database-id <db> --cursor "eyJsYXN0..." -o json
Required: --database-id
Optional:
| Flag | Default | Description |
|---|---|---|
--filter |
Filter: Key=Value or Key:operator=Value (repeatable, AND logic) |
|
--sort |
Sort: Property:asc or Property:desc (repeatable) |
|
--limit |
Max results per page (max 100) | |
--properties |
Property names to return (comma-separated) | |
--cursor |
Pagination cursor for next page |
Use schema --enhanced to discover available properties, types, and valid operators.
insert — Bulk insert records into a Notion database
mmk notion database insert --database-id <db> --data '{"Name":"Test","Status":"Active"}' -o json
mmk notion database insert --database-id <db> --data '[{"Name":"A"},{"Name":"B"}]' -o json
mmk notion database insert --database-id <db> --file records.json -o json
mmk notion database insert --database-id <db> --set Name=Test --set Status=Active -o json
Required: --database-id, one of --data, --file, --set, or piped stdin
Optional:
| Flag | Description |
|---|---|
--show-schema |
Show database schema and exit |
--icon-emoji |
Emoji icon for new pages |
--template-id |
Template page ID for new pages |
update — Bulk update existing Notion pages
mmk notion database update --data '{"page_id":"abc-123","Status":"Done"}' -o json
mmk notion database update --data '[{"page_id":"abc","Status":"Done"},{"page_id":"def","Status":"Active"}]' -o json
mmk notion database update --page-id abc-123 --set Status=Done --set Priority=High -o json
mmk notion database update --file updates.json -o json
Required: one of --data (each object must include page_id), --file, or --page-id + --set, or piped stdin
upsert — Bulk upsert records in a Notion database
mmk notion database upsert --database-id <db> --lookup Name --data '[{"Name":"Test","Status":"Done"}]' -o json
mmk notion database upsert --database-id <db> --lookup Name,Email --file records.json -o json
mmk notion database upsert --database-id <db> --lookup Name --update-properties Status,Priority --set Name=Test --set Status=Done -o json
Required: --database-id, --lookup (property names for matching, repeatable or comma-separated), one of --data, --file, --set, or piped stdin
Optional:
| Flag | Description |
|---|---|
--update-properties |
Property names to update on match (optional — updates all if omitted) |
--show-schema |
Show database schema and exit |
--icon-emoji |
Emoji icon for new pages |
--template-id |
Template page ID for new pages |
check-duplicates — Check which records already exist in a Notion database
Read-only check that matches each input record against existing database rows by the given lookup properties. Nothing is written. The response is a wrapper object with per-record results plus top-level unique_records and duplicate_records arrays.
mmk notion database check-duplicates --database-id <db> --lookup "Video URL" --data '[{"Video URL":"https://youtu.be/aaa"}]' -o json
mmk notion database check-duplicates --database-id <db> --lookup Name,Email --file candidates.json -o json
cat candidates.json | mmk notion database check-duplicates --database-id <db> --lookup "Video URL" -o json
To insert only the non-duplicate rows, extract the unique_records array first — do not pipe the raw wrapper into insert (it expects a JSON array of records, not the wrapper object):
mmk notion database check-duplicates --database-id <db> --lookup "Video URL" --file candidates.json -o json \
| jq '.unique_records' \
| mmk notion database insert --database-id <db> -o json
Required: a database target (one of --database-id, --data-source-id, or --notion-id), --lookup (property names for matching, repeatable or comma-separated), one of --data, --file, --set, or piped stdin
Optional:
| Flag | Description |
|---|---|
--data-source-id |
Notion data source ID (overrides --database-id) |
--notion-id |
Notion ID (auto-detect database or data source) |
Sources --data, --file, --set, and stdin are mutually exclusive.
delete — Bulk delete (archive) Notion pages
mmk notion database delete --page-id abc-123 --page-id def-456 -o json
mmk notion database delete --data '["abc-123","def-456"]' -o json
mmk notion database delete --file page_ids.json -o json
Required: one of --page-id (repeatable), --data (JSON array of ID strings), --file, or piped stdin
ai-summary — Trigger AI summary generation for database items
mmk notion database ai-summary --database-id <db-uuid> --page-id <page-1> --page-id <page-2> --property-id "prop_id" -o json
Required: --database-id, --page-id (string slice, repeatable), --property-id
Optional: --workflow-id
Limits: Max 10 page IDs per execution. Use schema --detect-ai first to discover --property-id and --workflow-id.
ai-summary-auto — Auto-discover AI properties and trigger summary generation
Combines schema AI detection and AI summary trigger into a single command. No need to manually find property-id or workflow-id — they are auto-detected.
mmk notion database ai-summary-auto --database-id <db-uuid> --page-id <page-1> --page-id <page-2> -o json
mmk notion database ai-summary-auto --database-id <db-uuid> --page-id <page-1> --db-page-id <page-from-url> -o json
mmk notion database ai-summary-auto --database-id <db-uuid> --page-id <page-1> --property-id "B\i_" -o json
Required: --database-id, --page-id (string slice, repeatable — pages to generate summaries for)
Optional:
| Flag | Description |
|---|---|
--db-page-id |
Database page ID for inline databases (optional) |
--property-id |
Filter to specific AI property ID(s) (repeatable) |
See Also
- mmk-shared — Auth, global flags, error handling
- mmk-notion — All Notion commands overview
- mmk-notion-page — Page invite, publish, and config
- mmk-notion-database-ai-summary — Bulk AI summary generation (recipe)
- mmk-paymint-notion-invoice — Batch Paymint invoice from Notion database (recipe)