Skip to content

Commit c685bcd

Browse files
committed
Added MONGO_DB_NAME and SCHEMAS_COLLECTION_NAME to settings
1 parent 621de80 commit c685bcd

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

jsoned/database.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010

1111
async def connect_to_mongo():
1212
global client, database, _schemas_collection
13+
1314
client = AsyncIOMotorClient(settings.MONGO_URI)
14-
database = client.jsoned_db
15-
_schemas_collection = database.schemas
15+
database = client[settings.MONGO_DB_NAME]
16+
_schemas_collection = database[settings.SCHEMAS_COLLECTION_NAME]
17+
1618
await _schemas_collection.create_index("title", unique=True)
1719

1820

jsoned/settings.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@
55
class Settings(BaseSettings):
66
PROJECT_NAME: str = "JSONed"
77
API_V1_STR: str = "/api/v1"
8+
9+
MONGO_URI: str = "mongodb://localhost:27017"
10+
MONGO_DB_NAME: str = "jsoned_db"
11+
SCHEMAS_COLLECTION_NAME: str = "schemas"
12+
813
BACKEND_CORS_ORIGINS: list[AnyHttpUrl] = [
914
"http://localhost",
1015
"http://localhost:3000",
1116
]
12-
MONGO_URI: str = "mongodb://localhost:27017"
1317

1418

1519
settings = Settings()

0 commit comments

Comments
 (0)