Live Messages SQL Predicates (store/live_messages.go)

msgvault · internal/store/live_messages.go · go · MIT
database, lang:go, tag:filtering

Defines SQL predicates for selecting live messages while filtering out deleted or source-deleted records. Reuse when implementing chat or message archive queries in Go.

// Source: https://github.com/obra/msgvault | License: MIT | Copyright 2025-2026 Wes McKinney
// Provided via justclaw.it.com; keep this notice with the code.
package store

import "fmt"

// liveMessages* cover the four (alias, hideDeletedFromSource)
// combinations on hot read paths; pre-computing them avoids a
// fmt.Sprintf allocation per call on list/search/count paths.
const (
	liveMessagesUnaliasedDedupOnly = "deleted_at IS NULL"
	liveMessagesUnaliasedFull      = "deleted_at IS NULL AND deleted_from_source_at IS NULL"
	liveMessagesMDedupOnly         = "m.deleted_at IS NULL"
	liveMessagesMFull              = "m.deleted_at IS NULL AND m.deleted_from_source_at IS NULL"
)

// LiveMessagesWhere returns the SQL predicate that selects live
// messages. Dedup-hidden rows (deleted_at IS NOT N

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key