chat.collections.message

Attributes

_M

Classes

MessageCollection

Abstract base class for generic types.

Module Contents

chat.collections.message._M[source]
class chat.collections.message.MessageCollection(session: sqlalchemy.orm.Session, type: tuple[str, Ellipsis] | Literal['*'] | None = ..., channel_id: str = '*', newer_than: str | None = None, older_than: str | None = None, limit: int | None = None, load: Literal['older-first', 'newer-first'] = 'older-first')[source]
class chat.collections.message.MessageCollection(session: sqlalchemy.orm.Session, type: str, channel_id: str = '*', newer_than: str | None = None, older_than: str | None = None, limit: int | None = None, load: Literal['older-first', 'newer-first'] = 'older-first')

Bases: onegov.core.collection.GenericCollection[_M]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]):
    def __getitem__(self, key: KT) -> VT:
        ...
    # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT:
    try:
        return mapping[key]
    except KeyError:
        return default
type = '*'[source]
channel_id = '*'[source]
newer_than = None[source]
older_than = None[source]
limit = None[source]
load = 'older-first'[source]
property model_class: type[_M][source]
add(*, channel_id: str, owner: str | None = None, type: str | None = None, meta: dict[str, Any] = ..., text: str | None = None, created: datetime.datetime = ..., updated: datetime | None = ..., file: MessageFile | None = None, **kwargs: Any) _M[source]
add(**kwargs: Any) _M
query() Query[_M][source]

Queries the messages with the given parameters.

latest_message(offset: int = 0) _M | None[source]

Returns the latest message in descending order (newest first).