本文整理汇总了Python中models.account.Account.fromjson方法的典型用法代码示例。如果您正苦于以下问题:Python Account.fromjson方法的具体用法?Python Account.fromjson怎么用?Python Account.fromjson使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.account.Account
的用法示例。
在下文中一共展示了Account.fromjson方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: find_one
# 需要导入模块: from models.account import Account [as 别名]
# 或者: from models.account.Account import fromjson [as 别名]
def find_one(cls, collection, field, value):
if collection == 'customers':
return Customer.fromjson(cls.db[collection].find_one({field: value}))
if collection == 'prepaids':
return Prepaid.fromjson(cls.db[collection].find_one({field: value}))
if collection == 'postpaids':
return Postpaid.fromjson(cls.db[collection].find_one({field: value}))
if collection == 'setups':
return Setup.fromjson(cls.db[collection].find_one({field: value}))
if collection == 'how_to_pays':
return HowToPay.fromjson(cls.db[collection].find_one({field: value}))
if collection == 'how_to_topups':
return HowToTopup.fromjson(cls.db[collection].find_one({field: value}))
if collection == 'accounts':
account = cls.db[collection].find_one({field: value})
if account is not None:
return Account.fromjson(cls.find_by_id('customers', account['customer']), cls.find_by_id('prepaids', account['package']), account)
else:
return None
if collection == 'bills':
bill = cls.db[collection].find({field: value}).sort('payment_date', -1)[0]
if bill is not None:
return Bill.fromjson(bill, cls.find_by_id('customers', bill['customer']), cls.find_by_id('postpaids', bill['package']))
else:
return None
示例2: find_by_id
# 需要导入模块: from models.account import Account [as 别名]
# 或者: from models.account.Account import fromjson [as 别名]
def find_by_id(cls, collection, id):
if collection == 'customers':
return Customer.fromjson(cls.db[collection].find_one({'_id': ObjectId(id)}))
if collection == 'prepaids':
return Prepaid.fromjson(cls.db[collection].find_one({'_id': ObjectId(id)}))
if collection == 'postpaids':
return Postpaid.fromjson(cls.db[collection].find_one({'_id': ObjectId(id)}))
if collection == 'accounts':
return Account.fromjson(cls.db[collection].find_one({'_id': ObjectId(id)}))
if collection == 'bills':
return Bill.fromjson(cls.db[collection].find_one({'_id': ObjectId(id)}))
示例3: find_list
# 需要导入模块: from models.account import Account [as 别名]
# 或者: from models.account.Account import fromjson [as 别名]
def find_list(cls, collection, field, value):
list = []
results = cls.db[collection].find({field: value})
for result in results:
if collection == 'customers':
list.append(Customer.fromjson(result))
elif collection == 'prepaids':
list.append(Prepaid.fromjson(result))
elif collection == 'postpaids':
list.append(Postpaid.fromjson(result))
elif collection == 'accounts':
list.append(Account.fromjson(result))
elif collection == 'bills':
list.append(Bill.fromjson(result))
return list