store_model.py
class DailyReport(Document):
meta = {
'collection' : 'daily_report'
}
store_id = StringField(required = True)
amount = FloatField(required = True)
bill_type = IntField(required = True)
bill_date = StringField(required = True)
sale = IntField()
store_helper.py
def save_dailyrecord(storeid,tamount,billtype,billdate):
dailyrecord = DailyReport()
dailyrecord.updateOne({'store_id' : storeid},
{
'$set' : {
'store_id' : storeid,
'bill_date' : billdate,
'bill_type' : billtype
},
'$inc' : {
'amount' : tamount,
'sale' : 1
}
},
upsert = True )
在执行此代码时出现如下错误:
回溯(最近通话最近): 在致电中,文件“ /home/swetha/venv/flaskproj/lib/python3.6/site-packages/flask/app.py”第2309行 返回self.wsgi_app(环境,start_response) wsgi_app中的文件“ /home/swetha/venv/flaskproj/lib/python3.6/site-packages/flask/app.py”,第2295行 响应= self.handle_exception(e) 包裹在函数中的文件“ /home/swetha/venv/flaskproj/lib/python3.6/site-packages/flask_cors/extension.py”,第161行 返回cors_after_request(app.make_response(f(* args,** kwargs))) 在handle_exception中,文件“ /home/swetha/venv/flaskproj/lib/python3.6/site-packages/flask/app.py”,行1741 加价(exc_type,exc_value,tb) 重新列出文件“ /home/swetha/venv/flaskproj/lib/python3.6/site-packages/flask/_compat.py”,第35行 提高价值 wsgi_app中的文件“ /home/swetha/venv/flaskproj/lib/python3.6/site-packages/flask/app.py”,第2292行 响应= self.full_dispatch_request() 在full_dispatch_request中,文件“ /home/swetha/venv/flaskproj/lib/python3.6/site-packages/flask/app.py”,行1815 rv = self.handle_user_exception(e) 包裹在函数中的文件“ /home/swetha/venv/flaskproj/lib/python3.6/site-packages/flask_cors/extension.py”,第161行 返回cors_after_request(app.make_response(f(* args,** kwargs))) 在handle_user_exception中,文件“ /home/swetha/venv/flaskproj/lib/python3.6/site-packages/flask/app.py”,行1718 加价(exc_type,exc_value,tb) 重新列出文件“ /home/swetha/venv/flaskproj/lib/python3.6/site-packages/flask/_compat.py”,第35行 提高价值 在full_dispatch_request中,文件“ /home/swetha/venv/flaskproj/lib/python3.6/site-packages/flask/app.py”,第1813行 rv = self.dispatch_request() 文件“ /home/swetha/venv/flaskproj/lib/python3.6/site-packages/flask/app.py”,行1799,在dispatch_request中 返回self.view_functionsrule.endpoint 在add_record中的文件“ /home/swetha/Desktop/reports_api/app/storing_reports/storedata.py”,第23行 save_dailyrecord(storeid,amount,billtype,billdate) 在save_dailyrecord中的文件“ /home/swetha/Desktop/reports_api/app/storing_reports/storehelper.py”,第49行 dailyrecord.updateOne({'store_id':storeid}, AttributeError:“ DailyReport”对象没有属性“ updateOne”