#!/usr/bin/env -S uv run --script

# /// script
# requires-python = ">=3.12"
# dependencies = ["pymongo"]
# ///

import sys
from datetime import datetime, timezone
from pymongo import MongoClient

if len(sys.argv) < 2:
    print("usage: ./add_note.py <note text>")
    sys.exit(1)

client = MongoClient(
    "mongodb://root:3wwfoUjyk2E2zWELXFlLuHqfw1ALlOp4pb2H5Vq3TImbMIHL2h1u8Jej2mjzCPl@docdb.connorrhodes.com:35563"
)
db = client["notes"]
col = db["journal"]

doc = {
    "note": sys.argv[1],
    "tags": ["examination_of_conscience"],
    "created_at": datetime.now(timezone.utc),
}

result = col.insert_one(doc)
print(f"inserted {result.inserted_id}")
client.close()
