예제 #1
0
def remove(server, db_name, collection_name):
    q = request.dmango
    if not q.id:
        raise Exception('_id값이 비어있습니다')
    mongo = Dmango.find_collection(server, db_name=db_name, collection_name=collection_name)
    rv = mongo.remove(q.id)
    return dict(result=rv)
예제 #2
0
def inc(server, db_name, collection_name):
    q = request.dmango
    mongo = Dmango.find_collection(server,
                                   db_name=db_name,
                                   collection_name=collection_name)
    rv = mongo.inc(q.id, q.match)
    return dict(result=rv)
예제 #3
0
def contents_list(server, db_name, collection_name):
    q = request.dmango
    mongo = Dmango.find_collection(server,
                                   db_name=db_name,
                                   collection_name=collection_name)
    if q.id:
        rv = mongo.find(match={'_id': q.id})
        head_list = mongo.find(match={'_id': q.id})
        count = mongo.count(match={'_id': q.id})
    else:
        rv = mongo.find(match=q.match,
                        sort=q.sort,
                        start_idx=q.start_idx,
                        end_idx=q.end_idx)
        head_list = mongo.find(match=q.match,
                               sort=q.sort,
                               start_idx=q.start_idx,
                               end_idx=q.end_idx)
        count = mongo.count(match=q.match)
    # return dict(total=count,  page_num=q.page_num, page_size=q.page_size, result=rv)
    header = dict()
    for row in head_list:
        header.update({k: True for k in row})

    return render_template('admin/contents_list.html',
                           header=header.keys(),
                           result=rv,
                           total=count,
                           page_size=q.page_size,
                           page_num=q.page_num,
                           max_page=int(count / q.page_size) + 1)
예제 #4
0
def count(server, db_name, collection_name):
    q = request.dmango
    if q.id:
        raise Exception('find method is "_id" value not support.')
    mongo = Dmango.find_collection(server, db_name=db_name, collection_name=collection_name)
    count = mongo.count(match=q.match)
    return dict(total=count)
예제 #5
0
def save(server, db_name, collection_name):
    q = request.dmango
    q = q.match.update(q.id)
    mongo = Dmango.find_collection(server,
                                   db_name=db_name,
                                   collection_name=collection_name)
    rv = mongo.save(q)
    return dict(result=rv)
예제 #6
0
def detail(server, db_name, collection_name, _id):
    mongo = Dmango.find_collection(server,
                                   db_name=db_name,
                                   collection_name=collection_name)
    doc = mongo.find_one({'_id': ObjectId(_id)})
    return render_template('admin/detail.html',
                           data_types={},
                           result=doc if doc else dict())
예제 #7
0
def remove(server, db_name, collection_name):
    q = request.dmango
    if not q.id:
        raise Exception('_id값이 비어있습니다')
    mongo = Dmango.find_collection(server,
                                   db_name=db_name,
                                   collection_name=collection_name)
    rv = mongo.remove(q.id)
    return dict(result=rv)
예제 #8
0
def count(server, db_name, collection_name):
    q = request.dmango
    if q.id:
        raise Exception('find method is "_id" value not support.')
    mongo = Dmango.find_collection(server,
                                   db_name=db_name,
                                   collection_name=collection_name)
    count = mongo.count(match=q.match)
    return dict(total=count)
예제 #9
0
def find(server, db_name, collection_name):
    q = request.dmango
    mongo = Dmango.find_collection(server, db_name=db_name, collection_name=collection_name)
    if q.id:
        rv = mongo.find(match={'_id': q.id}, fields=q.fields)
        count = mongo.count(match={'_id': q.id})
    else:
        rv = mongo.find(match=q.match, sort=q.sort, fields=q.fields, start_idx=q.start_idx, end_idx=q.end_idx)
        count = mongo.count(match=q.match)
    return dict(total=count,  page_num=q.page_num, page_size=q.page_size, result=rv)
예제 #10
0
def find_one(server, db_name, collection_name):
    q = request.dmango
    mongo = Dmango.find_collection(server, db_name=db_name, collection_name=collection_name)
    if q.id:
        rv = mongo.find_one(match={'_id': q.id}, fields=q.fields)
        count = mongo.count(match={'_id': q.id})
    else:
        rv = mongo.find_one(match=q.match, fields=q.fields)
        count = mongo.count(match=q.match)
    return dict(total=count, result=rv)
예제 #11
0
def find_one(server, db_name, collection_name):
    q = request.dmango
    mongo = Dmango.find_collection(server,
                                   db_name=db_name,
                                   collection_name=collection_name)
    if q.id:
        rv = mongo.find_one(match={'_id': q.id}, fields=q.fields)
        count = mongo.count(match={'_id': q.id})
    else:
        rv = mongo.find_one(match=q.match, fields=q.fields)
        count = mongo.count(match=q.match)
    return dict(total=count, result=rv)
예제 #12
0
def string_group(server, db_name, collection_name):
    """
    http://localhost:5000/dmango/server1.sada9_dev.testdb/string_group?_group=cate_nm&_unwind=cate_nm&_page_num=2&_page_size=5
    @param server:
    @param db_name:
    @param collection_name:
    @return:
    """
    q = request.dmango
    mongo = Dmango.find_collection(server, db_name=db_name, collection_name=collection_name)
    limit = q.end_idx + 1
    rv = mongo.string_group(q.match, group_fields=q.group, limit=limit, unwind_fields=q.unwind)
    return dict(result=rv[q.start_idx:])
예제 #13
0
def contents_list(server, db_name, collection_name):
    q = request.dmango
    mongo = Dmango.find_collection(server, db_name=db_name, collection_name=collection_name)
    if q.id:
        rv = mongo.find(match={'_id': q.id})
        head_list = mongo.find(match={'_id': q.id})
        count = mongo.count(match={'_id': q.id})
    else:
        rv = mongo.find(match=q.match, sort=q.sort, start_idx=q.start_idx, end_idx=q.end_idx)
        head_list = mongo.find(match=q.match, sort=q.sort, start_idx=q.start_idx, end_idx=q.end_idx)
        count = mongo.count(match=q.match)
    # return dict(total=count,  page_num=q.page_num, page_size=q.page_size, result=rv)
    header = dict()
    for row in head_list:
        header.update({k: True for k in row})

    return render_template('admin/contents_list.html', header=header.keys(), result=rv, total=count,
                           page_size=q.page_size, page_num=q.page_num, max_page=int(count/q.page_size)+1)
예제 #14
0
def string_group(server, db_name, collection_name):
    """
    http://localhost:5000/dmango/server1.sada9_dev.testdb/string_group?_group=cate_nm&_unwind=cate_nm&_page_num=2&_page_size=5
    @param server:
    @param db_name:
    @param collection_name:
    @return:
    """
    q = request.dmango
    mongo = Dmango.find_collection(server,
                                   db_name=db_name,
                                   collection_name=collection_name)
    limit = q.end_idx + 1
    rv = mongo.string_group(q.match,
                            group_fields=q.group,
                            limit=limit,
                            unwind_fields=q.unwind)
    return dict(result=rv[q.start_idx:])
예제 #15
0
def find(server, db_name, collection_name):
    q = request.dmango
    mongo = Dmango.find_collection(server,
                                   db_name=db_name,
                                   collection_name=collection_name)
    if q.id:
        rv = mongo.find(match={'_id': q.id}, fields=q.fields)
        count = mongo.count(match={'_id': q.id})
    else:
        rv = mongo.find(match=q.match,
                        sort=q.sort,
                        fields=q.fields,
                        start_idx=q.start_idx,
                        end_idx=q.end_idx)
        count = mongo.count(match=q.match)
    return dict(total=count,
                page_num=q.page_num,
                page_size=q.page_size,
                result=rv)
예제 #16
0
def save(server, db_name, collection_name):
    q = request.dmango
    q = q.match.update(q.id)
    mongo = Dmango.find_collection(server, db_name=db_name, collection_name=collection_name)
    rv = mongo.save(q)
    return dict(result=rv)
예제 #17
0
def insert(server, db_name, collection_name):
    q = request.dmango
    mongo = Dmango.find_collection(server, db_name=db_name, collection_name=collection_name)
    rv = mongo.insert(q.match)
    return dict(result=rv)
예제 #18
0
def detail(server, db_name, collection_name, _id):
    mongo = Dmango.find_collection(server, db_name=db_name, collection_name=collection_name)
    doc = mongo.find_one({'_id': ObjectId(_id)})
    return render_template('admin/detail.html', data_types={}, result=doc if doc else dict())