[Add]MainEngine增加dbDelete功能
This commit is contained in:
parent
19f559f36a
commit
b92eea8978
@ -137,3 +137,4 @@ DATABASE_CONNECTING_FAILED = u'MongoDB连接失败'
|
|||||||
DATA_INSERT_FAILED = u'数据插入失败,MongoDB没有连接'
|
DATA_INSERT_FAILED = u'数据插入失败,MongoDB没有连接'
|
||||||
DATA_QUERY_FAILED = u'数据查询失败,MongoDB没有连接'
|
DATA_QUERY_FAILED = u'数据查询失败,MongoDB没有连接'
|
||||||
DATA_UPDATE_FAILED = u'数据更新失败,MongoDB没有连接'
|
DATA_UPDATE_FAILED = u'数据更新失败,MongoDB没有连接'
|
||||||
|
DATA_DELETE_FAILED = u'数据删除失败,MongoDB没有连接'
|
@ -138,3 +138,4 @@ DATABASE_CONNECTING_FAILED = u'Failed to connect to MongoDB.'
|
|||||||
DATA_INSERT_FAILED = u'Data insert failed,please connect MongoDB first.'
|
DATA_INSERT_FAILED = u'Data insert failed,please connect MongoDB first.'
|
||||||
DATA_QUERY_FAILED = u'Data query failed, please connect MongoDB first.'
|
DATA_QUERY_FAILED = u'Data query failed, please connect MongoDB first.'
|
||||||
DATA_UPDATE_FAILED = u'Data update failed, please connect MongoDB first.'
|
DATA_UPDATE_FAILED = u'Data update failed, please connect MongoDB first.'
|
||||||
|
DATA_DELETE_FAILED = u'Data delete failed, please connect MongoDB first.'
|
@ -253,6 +253,16 @@ class MainEngine(object):
|
|||||||
else:
|
else:
|
||||||
self.writeLog(text.DATA_UPDATE_FAILED)
|
self.writeLog(text.DATA_UPDATE_FAILED)
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
def dbDelete(self, dbName, collectionName, flt):
|
||||||
|
"""从数据库中删除数据,flt是过滤条件"""
|
||||||
|
if self.dbClient:
|
||||||
|
db = self.dbClient[dbName]
|
||||||
|
collection = db[collectionName]
|
||||||
|
collection.delete_one(flt)
|
||||||
|
else:
|
||||||
|
self.writeLog(text.DATA_DELETE_FAILED)
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
def dbLogging(self, event):
|
def dbLogging(self, event):
|
||||||
"""向MongoDB中插入日志"""
|
"""向MongoDB中插入日志"""
|
||||||
|
Loading…
Reference in New Issue
Block a user