Skip to content

Instantly share code, notes, and snippets.

@mccraigmccraig
Created May 9, 2023 14:02
Show Gist options
  • Save mccraigmccraig/2a7c609048dc7d4d078f98937e9b528f to your computer and use it in GitHub Desktop.
Save mccraigmccraig/2a7c609048dc7d4d078f98937e9b528f to your computer and use it in GitHub Desktop.
(def ConversationMessage
[:map
[:org_id :string]
[:conversation_id :string]
[:id :string]
[:message_time :string]])
(coll/def-collection
"conversation-messages"
{::coll.md/key-specs
{::conversation-message-id
[:org_id :conversation_id :id]
::conversation-message-time
[:org_id
:conversation_id
[:message_time
{::coll.md.kc/sort-order ::coll.md.kc.so/desc}]]}
::coll.md/primary-key ::conversation-message-id
::coll.md/index-keys
[::conversation-message-time]
::coll.md/value-schema ConversationMessage
::coll.md/index-apis
{::conversation-message-time
{::coll.md.api/start-page-path-template
(str "/api/orgs/{{auth-info.org-id}}"
"/conversations/{{key-data.conversation_id}}/messages"
"?limit={{query-opts.limit}}")
::coll.md.api/next-page-path-template
(str "/api/orgs/{{auth-info.org-id}}"
"/conversations/{{key-data.conversation_id}}/messages"
"?limit={{query-opts.limit}}"
"&before-message-id={{last-record.id}}")
::coll.md.api/previous-page-path-template
(str "/api/orgs/{{auth-info.org-id}}"
"/conversations/{{key-data.conversation_id}}/messages"
"?limit={{query-opts.limit}}"
"&after-message-id={{first-record.id}}")
;; response contains just a raw list of conversation_messages
::coll.md.api/response-value-path nil}}})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment