# Poco::MongoDB

# class Cursor

Library: MongoDB
Package: MongoDB
Header: Poco/MongoDB/Cursor.h

## Description

Cursor is an helper class for querying multiple documents.

## Inheritance

Direct Base Classes: Document

All Base Classes: Document

## Member Summary

Member Functions: kill, next, query

Inherited Functions: add, addElement, addNewDocument, clear, elementNames, empty, exists, get, getInteger, isType, read, size, toString, write

## Constructors

### Cursor

Cursor(
const Document & aggregationResponse
);

Creates a Cursor for the given agregation query response.

### Cursor

Cursor(
const std::string & fullCollectionName,
QueryRequest::Flags flags = QueryRequest::QUERY_DEFAULT
);

Creates a Cursor for the given database and collection ("database.collection"), using the specified flags.

### Cursor

Cursor(
const std::string & dbname,
const std::string & collectionName,
QueryRequest::Flags flags = QueryRequest::QUERY_DEFAULT
);

Creates a Cursor for the given database and collection, using the specified flags.

## Destructor

### ~Cursor

virtual ~Cursor();

Destroys the Cursor.

## Member Functions

### kill

void kill(
Connection & connection
);

Kills the cursor and reset it so that it can be reused.

### next

ResponseMessage & next(
Connection & connection
);

Tries to get the next documents. As long as ResponseMessage has a cursor ID next can be called to retrieve the next bunch of documents.

The cursor must be killed (see kill()) when not all documents are needed.

### query

QueryRequest & query();

Returns the associated query.