template<typename T, typename Container = std::vector<T>>
page class
A page is a subset of documents drawn from a MongoDB collection.
Contents
Constructors, destructors, conversion operators
- page(Container&& collection, const std::size_t total)
- Default constructor.
Public functions
- auto count() const -> std::size_t
- The size of this page.
- auto total() const -> std::size_t
- The MongoDB collection's total size.
- auto at(std::size_t pos) const -> T
- Obtain a document from this page.
- auto to_json() const -> web::json::value
- Create and return a JSON object representation of the collection.
Function documentation
template<typename T, typename Container>
ops:: page<T, Container>:: page(Container&& collection,
const std::size_t total)
Default constructor.
Parameters | |
---|---|
collection | an STL collection of ops:: |
total | the total number of documents available in the underlying MongoDB data store at the time this subset was generated |
Typically, you would use ops::
template<typename T, typename Container>
std::size_t ops:: page<T, Container>:: count() const
The size of this page.
Returns | the number of documents in this collection. This number is often less than the number of documents available in the underlying MongoDB data store. |
---|
template<typename T, typename Container>
std::size_t ops:: page<T, Container>:: total() const
The MongoDB collection's total size.
Returns | the total number of documents available in the MongoDB collection at the time this subset was generated. |
---|
template<typename T, typename Container>
T ops:: page<T, Container>:: at(std::size_t pos) const
Obtain a document from this page.
Parameters | |
---|---|
pos | position of the element to return |
Returns | the ops:: |
template<typename T, typename Container>
web::json::value ops:: page<T, Container>:: to_json() const
Create and return a JSON object representation of the collection.
Returns | a JSON object enclosing the array of documents |
---|
auto collection = pants::page(0, 3); std::cout << collection.to_json().serialize() << std::endl;
Example output:
{ "pants": [ { "type": "party" }, { "type": "fancy" }, { "type": "smart" } ], "count": 3, "total": 300 }