content: import 'dart:developer';
  
  import 'package:cloud_firestore/cloud_firestore.dart';
  
  final FirebaseFirestore _firestore = FirebaseFirestore.instance;
  final CollectionReference _mainCollection = _firestore.collection('notes');
  
  class Database {
    static String? userUid;
  
    static Future<void> addItem({
      required String title,
      required String description,
    }) async {
      DocumentReference documentReferencer =
          _mainCollection.doc(userUid).collection('items').doc();
  
      Map<String, dynamic> data = <String, dynamic>{
        "title": title,
        "description": description,
      };
  
      await documentReferencer
          .set(data)
          .whenComplete(() => log("Note item added to the database"))
          .catchError((e) => log(e));
    }
  
    static Future<void> updateItem({
      required String title,
      required String description,
      required String docId,
    }) async {
      DocumentReference documentReferencer =
          _mainCollection.doc(userUid).collection('items').doc(docId);
  
      Map<String, dynamic> data = <String, dynamic>{
        "title": title,
        "description": description,
      };
  
      await documentReferencer
          .update(data)
          .whenComplete(() => log("Note item updated in the database"))
          .catchError((e) => log(e));
    }
  
    static Stream<QuerySnapshot> readItems() {
      CollectionReference notesItemCollection =
          _mainCollection.doc(userUid).collection('items');
  
      return notesItemCollection.snapshots();
    }
  
    static Future<void> deleteItem({
      required String docId,
    }) async {
      DocumentReference documentReferencer =
          _mainCollection.doc(userUid).collection('items').doc(docId);
  
      await documentReferencer
          .delete()
          .whenComplete(() => log('Note item deleted from the database'))
          .catchError((e) => log(e));
    }
  }
  