pub struct Node<'a> { /* private fields */ }
Expand description
Represents a node in the Firebase Realtime Database.
Nodes are used to traverse the database hierarchy and perform operations at specific paths. Each node maintains its full path and can create child nodes or perform CRUD operations.
The path is built incrementally using the builder pattern, allowing for fluent API usage.
§Example
use firebase_rtdb::{FirebaseRTDB, RtdbError};
async fn example() -> Result<(), RtdbError> {
let mut db = FirebaseRTDB::new_from_jwt("https://your-project.firebaseio.com", "your-jwt-token", "your-api-key").await?;
let mut root = db.root().await?;
let users = root
.child("users")
.child("user123")
.child("profile");
Ok(())
}
Implementations§
Source§impl Node<'_>
impl Node<'_>
Sourcepub fn final_node<T: AsRef<str>>(&mut self, node: T) -> &Self
pub fn final_node<T: AsRef<str>>(&mut self, node: T) -> &Self
Finalizes the node path with a last segment.
Similar to child() but returns an immutable reference, useful for immediately performing an operation.
Sourcepub async fn get(&self) -> Result<String, RtdbError>
pub async fn get(&self) -> Result<String, RtdbError>
Retrieves data at the current node path.
Performs a GET request to fetch the current value at this database location.
Sourcepub async fn put<T: Serialize>(&self, input: T) -> Result<String, RtdbError>
pub async fn put<T: Serialize>(&self, input: T) -> Result<String, RtdbError>
Writes data to the current node path.
Performs a PUT request to set the value at this database location. The input must be serializable to JSON.
Sourcepub async fn post<T: Serialize>(&self, input: T) -> Result<String, RtdbError>
pub async fn post<T: Serialize>(&self, input: T) -> Result<String, RtdbError>
Creates a new child with a unique key.
Performs a POST request to create a new child with a Firebase-generated key and the provided data.