adding new features to the documentation

This commit is contained in:
Blake Eggleston
2013-03-05 22:24:26 -08:00
parent f1119db1c2
commit 61235126bf
3 changed files with 94 additions and 2 deletions

View File

@@ -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
==============

View File

@@ -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
--------------

View File

@@ -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