## Manager


Usage

``` python
Manager()
```


## Methods

| Name | Description |
|----|----|
| [__contains__()](#__contains__) | Return whether primary key is present using [exists](QuerySet.md#model_values.QuerySet.exists). |
| [__delitem__()](#__delitem__) | Delete row with primary key. |
| [__getitem__()](#__getitem__) | Return [QuerySet](QuerySet.md#model_values.QuerySet) which matches primary key. |
| [bulk_change()](#bulk_change) | Update changed rows with a minimal number of queries, by inverting the data to use `pk__in`. |
| [bulk_changed()](#bulk_changed) | Return mapping of values which differ in the db. |
| [upsert()](#upsert) | Update or insert returning number of rows or created object. |

------------------------------------------------------------------------


#### \_\_contains\_\_()


Return whether primary key is present using [exists](QuerySet.md#model_values.QuerySet.exists).


Usage

``` python
__contains__(pk)
```


------------------------------------------------------------------------


#### \_\_delitem\_\_()


Delete row with primary key.


Usage

``` python
__delitem__(pk)
```


------------------------------------------------------------------------


#### \_\_getitem\_\_()


Return [QuerySet](QuerySet.md#model_values.QuerySet) which matches primary key.


Usage

``` python
__getitem__(pk)
```


To encourage direct db access, instead of always using get and save.


------------------------------------------------------------------------


#### bulk_change()


Update changed rows with a minimal number of queries, by inverting the data to use `pk__in`.


Usage

``` python
bulk_change(field, data, key="pk", conditional=False, **kwargs)
```


##### Parameters


`field`  
value column

`data: Mapping`  
`{pk: value, ...}`

`key: str = ``"pk"`  
unique key column

`conditional=``False`  
execute select query and single conditional update; may be more efficient if the percentage of changed rows is relatively small

`**kwargs`  
additional fields to be updated


------------------------------------------------------------------------


#### bulk_changed()


Return mapping of values which differ in the db.


Usage

``` python
bulk_changed(field, data, key="pk")
```


##### Parameters


`field`  
value column

`data: Mapping`  
`{pk: value, ...}`

`key: str = ``"pk"`  
unique key column


------------------------------------------------------------------------


#### upsert()


Update or insert returning number of rows or created object.


Usage

``` python
upsert(defaults={}, **kwargs)
```


Faster and safer than `update_or_create`. Supports combined expression updates by assuming the identity element on insert: `F(...) + 1`.


##### Parameters


`defaults: Mapping = {}`\  
optional mapping which will be updated, as with `update_or_create`.
