smash2/db.py
2020-11-14 18:50:11 +00:00

21 lines
414 B
Python

import pymongo
connection = pymongo.MongoClient()
db = connection.smash
qdb = db.quotes
adb = db.accounts
def get_random_quote():
x = dict( qdb.aggregate([
{ "$match": { "hidden": False } },
{ "$sample": { "size": 1 } }
]) )
print(x)
return(x)
def add_quote(quote, tags, author):
qdb.insert_one({
"quote": quote,
"tags": tags,
"author": author
})