parent
0f203b01d3
commit
3106504f39
13 changed files with 234 additions and 36 deletions
|
@ -1,15 +1,20 @@
|
|||
from data.database import Messages
|
||||
from data.database import Messages, MediaType
|
||||
|
||||
|
||||
def get_messages():
|
||||
"""Query the data base for messages and returns a container of database message objects"""
|
||||
return Messages.select()
|
||||
return Messages.select(Messages, MediaType).join(MediaType)
|
||||
|
||||
def create(messages):
|
||||
"""Insert messages into the database."""
|
||||
inserted = []
|
||||
for message in messages:
|
||||
inserted.append(Messages.create(content=message['content']))
|
||||
severity = message['severity']
|
||||
media_type_name = message['media_type']
|
||||
media_type = MediaType.get(name=media_type_name)
|
||||
|
||||
inserted.append(Messages.create(content=message['content'], media_type=media_type,
|
||||
severity=severity))
|
||||
return inserted
|
||||
|
||||
def delete_message(uuids):
|
||||
|
|
Reference in a new issue