mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-10 04:19:26 +08:00
update
This commit is contained in:
@@ -7,6 +7,8 @@ import time
|
||||
import re
|
||||
import pymongo
|
||||
|
||||
from bson.objectid import ObjectId
|
||||
|
||||
sys.path.append(os.getcwd() + "/class/core")
|
||||
import mw
|
||||
|
||||
@@ -174,6 +176,23 @@ class nosqlMongodbCtr():
|
||||
|
||||
return mw.returnData(True,'ok', rdata)
|
||||
|
||||
def delById(self,args):
|
||||
sid = args['sid']
|
||||
db = args['db']
|
||||
collection = args['collection']
|
||||
|
||||
mgdb_instance = self.getInstanceBySid(sid).mgdb_conn()
|
||||
if mgdb_instance is False:
|
||||
return mw.returnData(False,'无法链接')
|
||||
|
||||
db_instance = mgdb_instance[db]
|
||||
collection_instance = db_instance[collection]
|
||||
|
||||
_id = args['_id']
|
||||
result = collection_instance.delete_one({"_id": ObjectId(_id)})
|
||||
|
||||
return mw.returnData(True,'文档删除【%d】个成功!' % result.deleted_count)
|
||||
|
||||
# ---------------------------------- run ----------------------------------
|
||||
# 获取 mongodb databases 列表
|
||||
def get_db_list(args):
|
||||
@@ -206,6 +225,10 @@ def clear_flushdb(args):
|
||||
t = nosqlMongodbCtr()
|
||||
return t.clearFlushDB(args)
|
||||
|
||||
def del_by_id(args):
|
||||
t = nosqlMongodbCtr()
|
||||
return t.delById(args)
|
||||
|
||||
# 测试
|
||||
def test(args):
|
||||
sid = args['sid']
|
||||
|
||||
@@ -39,9 +39,11 @@
|
||||
</div>
|
||||
|
||||
<div class="search" id="mongodb_search"></div>
|
||||
<!--
|
||||
<button type="button" title="刷新" class="refresh btn btn-success btn-sm mr5 ml5" style="float:right;">
|
||||
<span>查找</span>
|
||||
</button>
|
||||
-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -145,8 +147,6 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="pull-right" style="padding-top: 5px;">
|
||||
<div class="item_list" style="float:left;">
|
||||
<select name="item" class="bt-input-text c5 mr5">
|
||||
|
||||
@@ -495,7 +495,7 @@ function mongodbDataList(p){
|
||||
}
|
||||
|
||||
tbody += '<td style="text-align:right;">\
|
||||
<a href="javascript:;" data-index="'+i+'" class="btlink" title="删除">删除</a>\
|
||||
<a href="javascript:;" data-index="'+i+'" class="btlink del" title="删除">删除</a>\
|
||||
</td>';
|
||||
|
||||
tbody += '</tr>';
|
||||
@@ -506,10 +506,29 @@ function mongodbDataList(p){
|
||||
$('#mongodb').css('width',$(document).width()-240).css('overflow','hidden');
|
||||
$('.mongodb_table tbody').html(tbody);
|
||||
$('.mongodb_list_page').html(data.page);
|
||||
|
||||
$('.del').click(function(){
|
||||
var i = $(this).data('index');
|
||||
mongodbDel(dlist[i]['_id']['$oid']);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function mongodbDel(mgdb_id){
|
||||
console.log(mgdb_id);
|
||||
var sid = mongodbGetSid();
|
||||
var db = mongodbGetDbName();
|
||||
var collection = mongodbCollectionName();
|
||||
mgdbPostCB('del_by_id',{'sid':sid,'db':db,'collection':collection,"_id":mgdb_id} ,function(rdata){
|
||||
showMsg(rdata.data.msg,function(){
|
||||
if (rdata.data.status){
|
||||
mongodbDataList(1);
|
||||
}
|
||||
},{icon: rdata.data.status ? 1 : 2}, 2000);
|
||||
});
|
||||
}
|
||||
|
||||
// ------------------------- mongodb end ---------------------------------
|
||||
|
||||
// ------------------------- redis start ---------------------------------
|
||||
|
||||
Reference in New Issue
Block a user