100 static std::string generateID()
102 static std::atomic<int> counter {0};
103 return "doc_" + std::to_string(counter++);
A class representing a dictionary that stores key-value pairs.
T & get(const std::string &key)
Retrieves the value associated with the given key, casting it to the specified type.
A class representing a document in a database.
Document()
Constructs a Document with a unique ID.
bool validate() const
Validates the Document.
Document(Dictionary &&dict, DocumentValidator validator=hasId)
Constructs a Document from the given Dictionary, moving its entries.
std::string id() const
Retrieves the ID of the Document.
Document(const Dictionary &dict, DocumentValidator validator=hasId)
Constructs a Document with the given Dictionary and validator.
Integer types used throughout NeoN.
std::function< bool(const Dictionary &)> DocumentValidator
A type alias for a function that validates a Dictionary object.
const std::string & name(const NeoN::Document &doc)
Retrieves the name of a Document.
bool hasId(const Dictionary &doc)
Checks if a Dictionary object has an "id" key.