# Snapshots

> UStore for C++

`#include <ustore/db.hpp>`

## snapshot_t

A point-in-time view of the whole database, which reads through it see until its destructor frees it.

```cpp
class snapshot_t
```

It owns its handle, never copies, and holds its database open until destroyed, so it may outlive its `[database_t](https://www.unum.cloud/docs/ustore/cpp/quickstart.md#database_t)`.

## snapshot_ref_t

A point-in-time view of the whole database, as the calls on one executor see it, without owning either.

```cpp
class snapshot_ref_t
```

It hands out read-only collections and proxies.

## snapshot_ref_t

```cpp
snapshot_ref_t() noexcept=default;
```

```cpp
snapshot_ref_t(receiver_t receiver) noexcept;
```

## on

The same snapshot, running every call on `executor`.

```cpp
snapshot_ref_t on(ustore_executor_t executor) const noexcept;
```

## deferred

The same snapshot, whose verbs submit to `executor` and answer deferred calls.

```cpp
deferred_snapshot_t deferred(ustore_executor_t executor) const noexcept;
```

## collections

Lists the collections at the snapshot, with their identifiers in `arena`.

```cpp
expected<collections_list_t> collections(arena_t & arena) noexcept;
```

## contains

Whether a collection named `name` exists at the snapshot.

```cpp
expected<bool> contains(std::string_view name) noexcept;
```

## find

Opens a read-only view of one collection at the snapshot.

```cpp
template <typename collection_type_ = blobs_collection_t>
expected<typename collection_type_::read_only_t> find(
    std::string_view name) noexcept;
```

## save

Saves the snapshot as a new database at `path`, reporting the bytes saved to `progress`, which may cancel the save and so remove what it wrote.

```cpp
status_t save(
    std::string_view path,
    progress_arg_t progress = {}) noexcept;
```

