using System.Text.Json;
using System.Text.Json.Nodes;
using QuipQuestDB;
var doc1Content = JsonNode.Parse(@"{""name"": ""Alice"", ""age"": 30, ""city"": ""Wonderland""}");
var doc2Content = JsonNode.Parse(@"{""name"": ""Bob"", ""age"": 25, ""city"": ""Builderland""}");
var doc3Content = JsonNode.Parse(@"{""name"": ""Charlie"", ""age"": 35, ""city"": ""Chocolate Factory""}");
var query = JsonNode.Parse(@"{""age"": 30}");

var database = new Database("shiza");
var collection = database.AddCollection("skibida");
var index = collection.AddDocument(doc1Content);
// collection.UpdateDocument(index, "{\"nickname\": \"Not_A_Skibida\", \"age\": 29}");
var document = collection.GetDocument(index);

Console.WriteLine(document);
collection.GetAllDocuments().ForEach(Console.WriteLine);

collection.Find(query);
using System.Text.Json;
using System.Text.Json.Nodes;
using NanoidDotNet;

namespace QuipQuestDB;

public class Document
{
    public JsonNode Content { get; set; }
    public DateTime CreatedAt { get; set; }

    public Document(JsonNode content)
    {
        Content = content;
        CreatedAt = DateTime.UtcNow;
    }

    public override string ToString()
    {
        return JsonSerializer.Serialize(this);
    }
}

public class Collection
{
    public string Name { get; set; }
    private Dictionary<string, Document> Documents { get; set; } = [];

    public List<Document> Find(JsonNode query)
    {
        var list = Documents.Values
            .Where(document => MatchValue(document.Content, query))
            .ToList();

        return list;
    }

    private bool MatchValue(JsonNode document, JsonNode query)
    {
        if (query is JsonObject jsonQueryObject)
        {
            if (document is JsonObject jsonDocumentObject)
            {
                foreach (var kvp in jsonQueryObject)
                {
                    if (jsonDocumentObject.ContainsKey(kvp.Key)
                        && jsonDocumentObject.TryGetPropertyValue(kvp.Key, out var value)
                        && value != null
                        && kvp.Value.Equals(value.AsValue()))
                    {
                        return true;
                    }
                }
            }
        }

        return false;
    }

    public string AddDocument(JsonNode content)
    {
        var index = Nanoid.Generate(size: 10);
        var newDocument = new Document(content);
        Documents.Add(index, newDocument);
        return index;
    }

    public Document GetDocument(string index)
    {
        Documents.TryGetValue(index, out var document);
        return document ?? Documents.Values.First();
    }

    public List<Document> GetAllDocuments() => Documents.Select(x => x.Value).ToList();
    public IEnumerable<Document> GetAllDocumentsIterator() => Documents.Select(x => x.Value).AsEnumerable();
    public Document GetDocumentByIndex(string index) => GetDocument(index);

    public void UpdateDocument(string index, JsonNode content)
    {
        GetDocument(index).Content = content;
    }

    public Document RemoveDocument(string index)
    {
        var document = GetDocument(index);
        Documents.Remove(index);
        return document;
    }

    public Collection(string name)
    {
        Name = name;
    }
}

public class Database
{
    public string Name { get; set; }
    private Dictionary<string, Collection> Collections { get; set; } = [];

    public Database(string name)
    {
        Name = name;
    }

    public Collection AddCollection(string name)
    {
        var newCollection = new Collection(name);
        Collections.Add(name, newCollection);
        return newCollection;
    }

    public Collection GetCollection(string name)
    {
        Collections.TryGetValue(name, out var collection);
        return collection ?? Collections.First().Value;
    }

    public List<Collection> GetAllCollections() => Collections.Values.ToList();

    public IEnumerable<Collection> GetAllCollectionsIterator() => Collections.Values.AsEnumerable();

    public Collection RemoveCollection(string name)
    {
        var collection = GetCollection(name);
        Collections.Remove(name);
        return collection;
    }
}

Why it can't find value, if it's obviously here?