Base Model and Manager#

class patent_client.util.manager.Manager(config=None)[source]#

Manager Class

This class is essentially a configurable generator. It is intended to be initialized as an empty object at Model.objects. Users can then call methods to modify the manager. All methods should return a brand-new manager with the appropriate parameters re-set. The manager’s attributes are stored in a dictionary at Manager.config.

filter(*args, **kwargs) Self[source]#

Apply a new filtering condition

order_by(*args) Self[source]#

Specify the order that argument should be returned in

option(**kwargs) Self[source]#

Set a key:value option on the manager

limit(limit) Self[source]#

Limit the number of records that are returned

offset(offset) Self[source]#

Specify the number of records from the beginning from which to apply an offset

async afirst() ModelType[source]#

Get the first object in the manager

first() ModelType[source]#

Get the first object in the manager

async aget(*args, **kwargs) ModelType[source]#

If the critera results in a single record, return it, else raise an exception

count() int[source]#

Returns number of records in the QuerySet. Alias for len(self)

all() Manager[ModelType][source]#

Return self. Does nothing

async ato_json(*args, **kwargs) str#

Convert objects to JSON format

async ato_list() List[T]#

Return a list of item objects from the Collection

async ato_pandas(annotate=[]) pandas.DataFrame#

Convert Collection into a Pandas DataFrame

explode(attribute, unpack=False, connector='.', prefix=True) Union[UnpackedCollection, ExplodedCollection]#

Implement an “explode” function for nested listed objects.

to_json(*args, **kwargs) str#

Convert objects to JSON format

to_list() List[T]#

Return a list of item objects from the Collection

to_mongo() List[dict]#

Return a list of dictionaries containing MongoDB compatible datatypes

to_pandas(annotate=[]) pandas.DataFrame#

Convert Collection into a Pandas DataFrame

to_records(item_class=<class 'dict'>, collection_class=<class 'list'>) List[dict]#

Return a list of dictionaries containing item data in ordinary Python types Useful for ingesting into NoSQL databases

unpack(attribute, connector='.', prefix=True) UnpackedCollection#

Implement an “unpack” function for nested single objects

values(*fields, **kw_fields) ValuesCollection#

Return a Collection that will return a Row object for each item with a subset of attributes positional arguments will result in Row objects where the fields match the field names on the item, keyword arguments can be used to rename attributes. When passed as key=field, the resulting dictionary will have key: item[field]

values_list(*fields, flat=False, **kw_fields) ValuesListCollection#

Return a Collection that will return tuples for each item with a subset of attributes. If only a single field is passed, the keyword argument “flat” can be passed to return a simple list