No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

datasource.py 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # -*- coding: utf-8 -*-
  2. class GenericDataSource(object):
  3. def __init__(self, *conn_args, **conn_kwargs):
  4. self.conn_args = conn_args
  5. self.conn_kwargs = conn_kwargs
  6. ## @brief returns a selection of documents from the datasource
  7. # @param target_cls Emclass
  8. # @param field_list list
  9. # @param filters list : List of filters
  10. # @param rel_filters list : List of relational filters
  11. # @param order list : List of column to order. ex: order = [('title', 'ASC'),]
  12. # @param group list : List of tupple representing the column to group together. ex: group = [('title', 'ASC'),]
  13. # @param limit int : Number of records to be returned
  14. # @param offset int: used with limit to choose the start record
  15. # @param instanciate bool : If true, the records are returned as instances, else they are returned as dict
  16. # @return list
  17. def select(self, target_cls, field_list, filters, rel_filters=None, order=None, group=None, limit=None, offset=0,
  18. instanciate=True):
  19. pass
  20. ## @brief Deletes one record defined by its uid
  21. # @param target_cls Emclass : class of the record to delete
  22. # @param uid dict|list : a dictionary of fields and values composing the unique identifier of the record or a list of several dictionaries
  23. # @return int : number of deleted records
  24. def delete(self, target_cls, uid):
  25. pass
  26. ## @brief updates one or a list of records
  27. # @param target_cls Emclass : class of the object to insert
  28. # @param uids list : list of uids to update
  29. # @param datas dict : datas to update (new values)
  30. # @return int : Number of updated records
  31. def update(self, target_cls, uids, **datas):
  32. pass
  33. ## @brief Inserts a record in a given collection
  34. # @param target_cls Emclass : class of the object to insert
  35. # @param datas dict : datas to insert
  36. # @return bool
  37. def insert(self, target_cls, **datas):
  38. pass
  39. ## @brief Inserts a list of records in a given collection
  40. # @param target_cls Emclass : class of the objects inserted
  41. # @param datas_list
  42. # @return list : list of the inserted records' ids
  43. def insert_multi(self, target_cls, datas_list):
  44. pass