# get

The .get() method for the SurrealDB Rust SDK retrieves the value at a certain field or index.

_(since v3.0.0)_

The `.get()` method for the `Value` struct retrieves the value at a certain field for an object, or a certain index for an array. The method takes a `&str` or a `usize` as an argument.

```rust title="Method Syntax"
value.get(target)
```

## Example usage

```rust
use surrealdb::engine::any::connect;
use surrealdb::types::{ToSql, Value};

#[tokio::main]
async fn main() -> surrealdb::Result<()> {
    let db = connect("mem://").await?;
    db.use_ns("main").use_db("main").await?;

    let mut res = db
        .query(
            "[
	{
		a: {
			big: [
				'nested',
				'object'
			]
		}
	},
	{
		another: {
			big: [
				'nested',
				'object'
			]
		}
	}
];",
        )
        .await?;
    let as_value = res.take::<Value>(0)?;
    // Get the value at index 0, field 'a'
    // Output: { big: ['nested', 'object'] }
    println!("{}", as_value.get(0).get("a").to_sql());
    Ok(())
}
```

As the `.get()` method will always return a `Value`, internally a `Value::None` is returned when nothing is found at a certain index or field. The methods `.is_none()` and `.into_option()` can be used on the `Value` struct to check if the `.get()` method has returned a non-None value or not.

## See also

* [.get() method on Docs.rs](https://docs.rs/surrealdb/latest/surrealdb/types/enum.Value.html#method.get)
