pub struct DataSet {
pub id: String,
pub value: Value,
}Expand description
Represents a data entry in a dataset, typically used for storing and retrieving structured data in a database.
This struct is used to represent an individual row or object in the dataset, where
each entry is identified by a unique id and can hold a dynamic value in the form of
a JSON object. The value field allows for flexible storage of various types of data
using the serde_json::Value type, which can represent different JSON structures like
strings, numbers, arrays, objects, or nulls.
§Fields
-
id: A unique identifier for the dataset entry. This is typically used as a primary key in database operations, ensuring that each entry can be retrieved, updated, or deleted based on its unique identifier. The ID is represented as aString, which can be a UUID or any other suitable format for identifying records. -
value: The actual data associated with this entry. This is stored as aserde_json::Valuetype, which is a flexible and powerful representation of any valid JSON data. This allows the driver to store various data types in the database without enforcing a rigid schema. The data stored here can be a string, a number, an array, an object, or any other valid JSON structure.
§Example Usage
use serde_json::{json, Value};
let data = DataSet {
id: "12345".to_string(),
value: json!({"key": "value", "age": 30}),
};In this example, data.id is the unique identifier "12345", and data.value is a JSON object
containing a string and a number.
Fields§
§id: StringUnique identifier for this data entry in the dataset.
value: ValueA flexible container for any JSON-compatible value. This can store a wide range of data structures such as strings, numbers, arrays, objects, etc.