def insert_timetable_document(self, timetable):
"""
Insert a new timetable_document or update, if it already exists in the database.
:param timetable: timetable_document
:return: new_object_id: ObjectId
"""
key = {
'_id': ObjectId(timetable.get('_id'))
}
data = {
'$set': {
'bus_line_id': timetable.get('bus_line_id'),
'timetable_entries': timetable.get('timetable_entries'),
'travel_requests': timetable.get('travel_requests')
}
}
result = self.timetable_documents_collection.update_one(key, data, upsert=True)
new_object_id = result.upserted_id
return new_object_id
mongodb_database_connection.py 文件源码
python
阅读 22
收藏 0
点赞 0
评论 0
评论列表
文章目录