initial
This commit is contained in:
21
app/storage/mongo/__init__.py
Normal file
21
app/storage/mongo/__init__.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import os
|
||||
import motor
|
||||
import motor.motor_asyncio
|
||||
import pymongo
|
||||
|
||||
|
||||
MONGO_HOST = os.getenv('MONGO_HOST', 'localhost')
|
||||
MONGO_PASSWORD = os.getenv('MONGO_PASSWORD', 'password')
|
||||
|
||||
CONNECTION_STRING = f'mongodb://mongo:{MONGO_PASSWORD}@{MONGO_HOST}:27017/'
|
||||
|
||||
|
||||
database: 'motor.MotorDatabase' = motor.motor_asyncio.AsyncIOMotorClient(CONNECTION_STRING).queues
|
||||
|
||||
def create_indexes():
|
||||
client = pymongo.MongoClient(CONNECTION_STRING)
|
||||
database = client.get_database('queues')
|
||||
database.get_collection('tasks').create_index([
|
||||
('queue', 1),
|
||||
('available_from', 1),
|
||||
])
|
||||
Reference in New Issue
Block a user