Skip to content

feat(59): Add Notion database destination support#60

Merged
Myastr0 merged 6 commits intomasterfrom
59/add-database-support
Nov 29, 2025
Merged

feat(59): Add Notion database destination support#60
Myastr0 merged 6 commits intomasterfrom
59/add-database-support

Conversation

@Myastr0
Copy link
Owner

@Myastr0 Myastr0 commented Nov 29, 2025

Add Notion Database Synchronization Support

Related to #59

Summary

This PR introduces support for synchronizing markdown files to Notion Databases in addition to Notion Pages. Users can now leverage Notion's powerful database features like filtering, sorting, and custom views for their synchronized content.


All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  1. Does your submission pass tests?
  2. Have you lint your code locally before submission?

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully run tests with your changes locally?

What's New

🗄️ Notion Database Support

You can now sync markdown files directly to Notion databases, enabling:

  • Better organization: Use Notion's table, board, gallery, or calendar views
  • Filtering & sorting: Quickly find content using database filters
  • Custom properties: Add metadata like status, tags, or dates to your pages
  • Scalability: Ideal for managing large collections of documents

📝 New Frontmatter Properties

id Property

A unique identifier for your page, used for clean sync operations when targeting databases:

---
id: my-unique-page-id
title: My Document Title
---

When clean sync is enabled with a database destination, MK Notes uses this id to find and delete existing pages with matching mk-notes-id property before creating new ones.

properties Array

Populate additional database properties directly from your markdown frontmatter:

---
id: api-auth-guide
title: Authentication Guide
properties:
  - name: status
    value: published
  - name: category
    value: API
---

🔄 Clean Sync Behavior

The --clean flag now behaves differently based on destination type:

Destination Clean Sync Behavior
Page Removes ALL existing content from the page before syncing
Database Finds and deletes existing pages with matching mk-notes-id before creating new ones

Technical Changes

Core Domain Changes

  • New Element System: Introduced a proper class hierarchy for elements (Element, PageElement, TextElement, CodeElement, etc.) with dedicated files for each element type
  • PageElement enhancements: Added mkNotesInternalId and properties fields to support database sync features
  • DestinationRepository interface updates:
    • Renamed getPageIdFromPageUrlgetObjectIdFromObjectUrl
    • Renamed parentPageIdparentObjectId with new parentObjectType parameter
    • Added getObjectType() to detect if destination is a page or database
    • Added getObjectIdInDatabaseByMkNotesInternalId() for clean sync lookups
    • Added getDataSourceIdFromDatabaseId() for database operations
    • Added deleteObjectById() for removing database entries

Infrastructure Changes

  • Notion Destination Repository:
    • Implemented database detection and datasource retrieval
    • Added support for creating pages in databases via data sources
    • Implemented mk-notes-id property lookup for clean sync
  • Markdown Parser: Extended to parse id and properties from frontmatter
  • Notion Converter: Updated to handle database properties and map them to Notion property types

Dependencies

  • Updated @notionhq/client from 5.1.0 to 5.4.0 to access the latest Notion API features (data sources API)

Documentation Updates

  • New Guide: Added comprehensive Database Synchronization guide
  • Updated CLI Commands: Added documentation for database sync examples and clean sync behavior differences
  • Updated Getting Started: Clarified that both Pages and Databases are supported destinations
  • Updated Styling Guide: Added documentation for the new id frontmatter property

Testing

  • Added unit tests for frontmatter parsing with id and properties
  • Updated existing synchronization tests to reflect new interface changes
  • All tests pass locally

Breaking Changes

None - existing page synchronization continues to work as before. Database sync is an additive feature.


Related Issue

Closes #59

@Myastr0
Copy link
Owner Author

Myastr0 commented Nov 29, 2025

👋 Hi, Myastr0! Thanks for opening a PR. We will review it soon.
If you have any questions, feel free to join the #need-help channel on the Discord server

@Myastr0 Myastr0 merged commit 1ba46cd into master Nov 29, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Question: Database as destination

1 participant