Ejemplo n.º 1
0
def upsert(detail):
    if type(detail) == list:
        return list(map(lambda d: upsert(d), detail))
    id = define_id(detail)
    entity = Datastore.upsert(KIND, detail, id=id)
    logger.debug('Upsert detail %s', id)
    return Datastore.entity_to_dict(entity)
Ejemplo n.º 2
0
def upsert(person):
    if type(person) == list:
        return list(map(lambda p: upsert(p), person))
    id = define_id(person)
    entity = Datastore.upsert(KIND, person, id=id)
    logger.debug('Upsert person %s', id)
    return Datastore.entity_to_dict(entity)
Ejemplo n.º 3
0
def upsert(cluster):
    if type(cluster) == list:
        return list(map(lambda c: upsert(c), cluster))
    id = define_id(cluster)
    entity = Datastore.upsert(KIND, cluster, id=id)
    logger.debug('Upsert cluster %s', id)
    return Datastore.entity_to_dict(entity)
Ejemplo n.º 4
0
def find(filters=[], order=[], offset=0, limit=None):
    entities = Datastore.find(KIND,
                              filters=filters,
                              order=order,
                              offset=offset,
                              limit=limit)
    details = list(map(lambda e: Datastore.entity_to_dict(e), entities))
    return details
Ejemplo n.º 5
0
def current_date():
    entities = Datastore.get_one_property(KIND,
                                          'release_date',
                                          order=['-release_date'],
                                          limit=1)
    if len(entities) == 0:
        return ''
    return Datastore.entity_to_dict(entities[0]['release_date'])
Ejemplo n.º 6
0
def delete(detail):
    if type(detail) == list:
        return list(map(lambda d: delete(d), detail))

    elif type(detail) == dict:
        id = define_id(detail)
    else:
        id = detail

    entity = Datastore.delete(KIND, id)
    logger.debug('delete %s', id)
    return Datastore.entity_to_dict(entity)
Ejemplo n.º 7
0
def delete(person):
    if type(person) == list:
        return list(map(lambda p: delete(p), person))

    elif type(person) == dict:
        id = define_id(person)
    else:
        id = person

    entity = Datastore.delete(KIND, id)
    logger.debug('delete %s', id)
    return Datastore.entity_to_dict(entity)
Ejemplo n.º 8
0
def delete(cluster):
    if type(cluster) == list:
        return list(map(lambda c: delete(c), cluster))

    elif type(cluster) == dict:
        id = define_id(cluster)
    else:
        id = cluster

    entity = Datastore.delete(KIND, id)
    logger.debug('delete %s', id)
    return Datastore.entity_to_dict(entity)
Ejemplo n.º 9
0
def find(filters=[], order=[], offset=0, limit=None):
    # persons = []
    # age_filters = list(filter(lambda f: f['key'] == 'age', filters))
    # if len(age_filters) > 0:
    #     age_filters[0].split(',')

    entities = Datastore.find(KIND,
                              filters=filters,
                              order=order,
                              offset=offset,
                              limit=limit)
    persons = list(map(lambda e: Datastore.entity_to_dict(e), entities))
    return persons
Ejemplo n.º 10
0
def count(filters=[]):
    return Datastore.count(KIND, filters=filters)
Ejemplo n.º 11
0
def find_by_government_no(government, no):
    id = _define_id(government, no)
    entity = Datastore.find_by_id(KIND, id)
    return Datastore.entity_to_dict(entity)
Ejemplo n.º 12
0
def find_by_id(id):
    entity = Datastore.find_by_id(KIND, id)
    return Datastore.entity_to_dict(entity)
Ejemplo n.º 13
0
def delete_by_no(person):
    if type(person) == list:
        return list(map(lambda p: delete_by_no(p), person))
    entity = Datastore.find_one(KIND, 'no', person['no'])

    return Datastore.delete(KIND, entity.key.id)
Ejemplo n.º 14
0
def get_last_no():
    nos = Datastore.get_one_property(KIND, 'no', order=['-no'], limit=1)
    if len(nos) == 0:
        return 0

    return nos[0]['no']
Ejemplo n.º 15
0
def find_by_no(no):
    id = _define_id(no)
    entity = Datastore.find_by_id(KIND, id)
    return Datastore.entity_to_dict(entity)