This document maps NIP-45 COUNT filter shapes to Primal Server cache methods that can provide the count data.
NIP-45 defines a COUNT verb for requesting event counts matching specific filters. Filter shapes are conceptually similar to PostgreSQL parameterized queries - they define patterns that can be satisfied by different parameters.
Primal Server doesn't implement NIP-45 directly, but provides specialized cache methods that return pre-computed count data in custom event kinds. This document shows how various COUNT filters can be implemented by calling appropriate Primal Server methods and extracting count values from structured response fields.
Important: All counts listed here are extracted from pre-computed fields in Primal's custom event kinds (10000100-10000200 range). We do NOT support counting the length of returned event arrays, as this would be inefficient and unreliable for large result sets.
The following NIP-45 COUNT filters can be resolved using Primal Server methods:
- {"kinds":[7],"#e":["<event-id>"]} → events (EVENT_STATS.likes)
- {"kinds":[1],"#e":["<event-id>"]} → events (EVENT_STATS.replies or EVENT_STATS.mentions)
- {"kinds":[6],"#e":["<event-id>"]} → events (EVENT_STATS.reposts)
- {"kinds":[9735],"#e":["<event-id>"]} → events (EVENT_STATS.zaps)
- {"kinds":[1],"authors":["<pubkey>"]} → user_profile (USER_PROFILE.note_count)
- {"kinds":[30023],"authors":["<pubkey>"]} → user_profile (USER_PROFILE.long_form_note_count)
- {"kinds":[3],"#p":["<pubkey>"]} → user_profile (USER_PROFILE.followers_count)