QDjango
|
The QDjangoQuerySet class is a template class for performing database queries. More...
#include <QDjangoQuerySet.h>
Classes | |
class | const_iterator |
Public Types | |
typedef const_iterator | ConstIterator |
Public Member Functions | |
QDjangoQuerySet () | |
QDjangoQuerySet (const QDjangoQuerySet< T > &other) | |
~QDjangoQuerySet () | |
QDjangoQuerySet | all () const |
QDjangoQuerySet | exclude (const QDjangoWhere &where) const |
QDjangoQuerySet | filter (const QDjangoWhere &where) const |
QDjangoQuerySet | limit (int pos, int length=-1) const |
QDjangoQuerySet | none () const |
QDjangoQuerySet | orderBy (const QStringList &keys) const |
QDjangoQuerySet | selectRelated () const |
int | count () const |
QDjangoWhere | where () const |
bool | remove () |
int | size () |
int | update (const QVariantMap &fields) |
QList< QVariantMap > | values (const QStringList &fields=QStringList()) |
QList< QVariantList > | valuesList (const QStringList &fields=QStringList()) |
T * | get (const QDjangoWhere &where, T *target=0) const |
T * | at (int index, T *target=0) |
const_iterator | constBegin () const |
const_iterator | begin () const |
const_iterator | constEnd () const |
const_iterator | end () const |
QDjangoQuerySet< T > & | operator= (const QDjangoQuerySet< T > &other) |
The QDjangoQuerySet class is a template class for performing database queries.
The QDjangoQuerySet template class allows you to define and manipulate sets of QDjangoModel objects stored in the database.
You can chain filter expressions using the filter() and exclude() methods or apply limits on the number of rows using the limit() method.
You can retrieve database values using the values() and valuesList() methods or retrieve model instances using the get() and at() methods.
You can also delete sets of objects using the remove() method.
Behinds the scenes, the QDjangoQuerySet class uses implicit sharing to reduce memory usage and avoid needless copying of data.
typedef const_iterator QDjangoQuerySet< T >::ConstIterator |
Qt-style synonym for QDjangoQuerySet::const_iterator.
QDjangoQuerySet< T >::QDjangoQuerySet | ( | ) |
Constructs a new queryset.
QDjangoQuerySet< T >::QDjangoQuerySet | ( | const QDjangoQuerySet< T > & | other | ) |
Constructs a copy of other.
other |
QDjangoQuerySet< T >::~QDjangoQuerySet | ( | ) |
Destroys the queryset.
QDjangoQuerySet< T > QDjangoQuerySet< T >::all | ( | ) | const |
Returns a copy of the current QDjangoQuerySet.
T * QDjangoQuerySet< T >::at | ( | int | index, |
T * | target = 0 |
||
) |
Returns the object in the QDjangoQuerySet at the given index.
Returns 0 if the index is out of bounds.
If target is 0, a new object instance will be allocated which you must free yourself.
index | |
target | optional existing model instance. |
QDjangoQuerySet< T >::const_iterator QDjangoQuerySet< T >::begin | ( | ) | const |
Returns a const STL-style iterator pointing to the first object in the QDjangoQuerySet.
QDjangoQuerySet< T >::const_iterator QDjangoQuerySet< T >::constBegin | ( | ) | const |
Returns a const STL-style iterator pointing to the first object in the QDjangoQuerySet.
QDjangoQuerySet< T >::const_iterator QDjangoQuerySet< T >::constEnd | ( | ) | const |
Returns a const STL-style iterator pointing to the imaginary object after the last object in the QDjangoQuerySet.
int QDjangoQuerySet< T >::count | ( | ) | const |
Counts the number of objects in the queryset using an SQL COUNT query, or -1 if the query failed.
If you intend to iterate over the results, you should consider using size() instead.
QDjangoQuerySet< T >::const_iterator QDjangoQuerySet< T >::end | ( | ) | const |
Returns a const STL-style iterator pointing to the imaginary object after the last object in the QDjangoQuerySet.
QDjangoQuerySet< T > QDjangoQuerySet< T >::exclude | ( | const QDjangoWhere & | where | ) | const |
Returns a new QDjangoQuerySet containing objects for which the given key where condition is false.
You can chain calls to filter() and exclude() to further refine the filtering conditions.
where | QDjangoWhere expressing the exclude condition |
QDjangoQuerySet< T > QDjangoQuerySet< T >::filter | ( | const QDjangoWhere & | where | ) | const |
Returns a new QDjangoQuerySet containing objects for which the given where condition is true.
You can chain calls to filter() and exclude() to progressively refine your filtering conditions.
where | QDjangoWhere expressing the filter condition |
T * QDjangoQuerySet< T >::get | ( | const QDjangoWhere & | where, |
T * | target = 0 |
||
) | const |
Returns the object in the QDjangoQuerySet for which the given where condition is true.
Returns 0 if the number of matching object is not exactly one.
If target is 0, a new object instance will be allocated which you must free yourself.
where | QDjangoWhere expressing the lookup condition |
target | optional existing model instance. |
QDjangoQuerySet< T > QDjangoQuerySet< T >::limit | ( | int | pos, |
int | length = -1 |
||
) | const |
Returns a new QDjangoQuerySet containing limiting the number of records to manipulate.
You can chain calls to limit() to further restrict the number of returned records.
However, you cannot apply additional restrictions using filter(), exclude(), get(), orderBy() or remove() on the returned QDjangoQuerySet.
pos | offset of the records |
length | maximum number of records |
QDjangoQuerySet< T > QDjangoQuerySet< T >::none | ( | ) | const |
Returns an empty QDjangoQuerySet.
QDjangoQuerySet< T > & QDjangoQuerySet< T >::operator= | ( | const QDjangoQuerySet< T > & | other | ) |
Assigns the specified queryset to this object.
other |
QDjangoQuerySet< T > QDjangoQuerySet< T >::orderBy | ( | const QStringList & | keys | ) | const |
Returns a QDjangoQuerySet whose elements are ordered using the given keys.
By default the elements will by in ascending order. You can prefix the key names with a "-" (minus sign) to use descending order.
keys |
bool QDjangoQuerySet< T >::remove | ( | ) |
Deletes all objects in the QDjangoQuerySet.
QDjangoQuerySet< T > QDjangoQuerySet< T >::selectRelated | ( | ) | const |
Returns a QDjangoQuerySet that will automatically "follow" foreign-key relationships, selecting that additional related-object data when it executes its query.
int QDjangoQuerySet< T >::size | ( | ) |
Returns the number of objects in the QDjangoQuerySet, or -1 if the query failed.
If you do not plan to access the objects, you should consider using count() instead.
int QDjangoQuerySet< T >::update | ( | const QVariantMap & | fields | ) |
Performs an SQL update query for the specified fields and returns the number of rows affected, or -1 if the update failed.
QList< QVariantMap > QDjangoQuerySet< T >::values | ( | const QStringList & | fields = QStringList() | ) |
Returns a list of property hashes for the current QDjangoQuerySet. If no fields are specified, all the model's declared fields are returned.
fields |
QList< QVariantList > QDjangoQuerySet< T >::valuesList | ( | const QStringList & | fields = QStringList() | ) |
Returns a list of property lists for the current QDjangoQuerySet. If no fields are specified, all the model's fields are returned in the order they where declared.
fields |
QDjangoWhere QDjangoQuerySet< T >::where | ( | ) | const |
Returns the QDjangoWhere expressing the WHERE clause of the QDjangoQuerySet.