From 61235126bf84b86aa71655d5383228355b0b53df Mon Sep 17 00:00:00 2001 From: Blake Eggleston Date: Tue, 5 Mar 2013 22:24:26 -0800 Subject: [PATCH] adding new features to the documentation --- docs/topics/columns.rst | 59 ++++++++++++++++++++++++++++++++++++++++ docs/topics/models.rst | 6 ++-- docs/topics/queryset.rst | 31 +++++++++++++++++++++ 3 files changed, 94 insertions(+), 2 deletions(-) diff --git a/docs/topics/columns.rst b/docs/topics/columns.rst index 9090b0bc..0537e3bc 100644 --- a/docs/topics/columns.rst +++ b/docs/topics/columns.rst @@ -77,6 +77,65 @@ Columns columns.Decimal() +Collection Type Columns +---------------------------- + + CQLEngine also supports container column types. Each container column requires a column class argument to specify what type of objects it will hold. The Map column requires 2, one for the key, and the other for the value + + *Example* + + .. code-block:: python + + class Person(Model): + first_name = columns.Text() + last_name = columns.Text() + + friends = columns.Set(columns.Text) + enemies = columns.Set(columns.Text) + todo_list = columns.List(columns.Text) + birthdays = columns.Map(columns.Text, columns.DateTime) + + + +.. class:: Set() + + Stores a set of unordered, unique values. Available only with Cassandra 1.2 and above :: + + columns.Set(value_type) + + **options** + + :attr:`~columns.Set.value_type` + The type of objects the set will contain + + :attr:`~columns.Set.strict` + If True, adding this column will raise an exception during save if the value is not a python `set` instance. If False, it will attempt to coerce the value to a set. Defaults to True. + +.. class:: List() + + Stores a list of ordered values. Available only with Cassandra 1.2 and above :: + + columns.List(value_type) + + **options** + + :attr:`~columns.List.value_type` + The type of objects the set will contain + +.. class:: Map() + + Stores a map (dictionary) collection, available only with Cassandra 1.2 and above :: + + columns.Map(key_type, value_type) + + **options** + + :attr:`~columns.Map.key_type` + The type of the map keys + + :attr:`~columns.Map.value_type` + The type of the map values + Column Options ============== diff --git a/docs/topics/models.rst b/docs/topics/models.rst index 86788a25..0dd2c19c 100644 --- a/docs/topics/models.rst +++ b/docs/topics/models.rst @@ -50,11 +50,13 @@ Column Types * :class:`~cqlengine.columns.Integer` * :class:`~cqlengine.columns.DateTime` * :class:`~cqlengine.columns.UUID` + * :class:`~cqlengine.columns.TimeUUID` * :class:`~cqlengine.columns.Boolean` * :class:`~cqlengine.columns.Float` * :class:`~cqlengine.columns.Decimal` - - A time uuid field is in the works. + * :class:`~cqlengine.columns.Set` + * :class:`~cqlengine.columns.List` + * :class:`~cqlengine.columns.Map` Column Options -------------- diff --git a/docs/topics/queryset.rst b/docs/topics/queryset.rst index 63b76d03..ce3a2c81 100644 --- a/docs/topics/queryset.rst +++ b/docs/topics/queryset.rst @@ -151,6 +151,33 @@ Filtering Operators q = Automobile.objects.filter(manufacturer='Tesla') q = q.filter(year__lte=2012) # year <= 2012 + +TimeUUID Functions +================== + + In addition to querying using regular values, there are two functions you can pass in when querying TimeUUID columns to help make filtering by them easier. Note that these functions don't actually return a value, but instruct the cql interpreter to use the functions in it's query. + + .. class:: MinTimeUUID(datetime) + + returns the minimum time uuid value possible for the given datetime + + .. class:: MaxTimeUUID(datetime) + + returns the maximum time uuid value possible for the given datetime + + *Example* + + .. code-block:: python + + class DataStream(Model): + time = cqlengine.TimeUUID(primary_key=True) + data = cqlengine.Bytes() + + min_time = datetime(1982, 1, 1) + max_time = datetime(1982, 3, 9) + + DataStream.filter(time__gt=cqlengine.MinTimeUUID(min_time), time__lt=cqlengine.MaxTimeUUID(max_time)) + QuerySets are imutable ====================== @@ -223,3 +250,7 @@ QuerySet method reference :type field_name: string Sets the field to order on. + + .. method:: allow_filtering() + + Enables the (usually) unwise practive of querying on a clustering key without also defining a partition key