PG→Mongo Ingest CLI - v1.0.0
    Preparing search index...

    Function getNthMostRecentBoundary

    • Gets metadata about the Nth most recent message in a specific chat.

      This function is used to implement "depth-based" filtering, where you want to import only the most recent N messages from a chat. It's useful for:

      • Limiting import scope to recent activity
      • Testing with a subset of data
      • Incremental imports focusing on recent messages

      Parameters

      • chat_id: string

        The chat ID to get the boundary message for

      • depth: number

        How many messages back from the latest to go (1 = second most recent)

      Returns Promise<null | { ts_seconds: number; message_id: string }>

      Promise resolving to message metadata or null if fewer than depth+1 messages exist

      // Get the 100th most recent message (start import from there)
      const boundary = await getNthMostRecentBoundary("19175769740@s.whatsapp.net", 100);
      if (boundary) {
      console.log(`Importing from message ${boundary.message_id} onwards`);
      }