Poco::MongoDB

class QueryRequest

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

Description

A request to query documents in a MongoDB database using an OP_QUERY request.

Inheritance

Direct Base Classes: RequestMessage

All Base Classes: Message, RequestMessage

Member Summary

Member Functions: buildRequest, fullCollectionName, getFlags, getNumberToReturn, getNumberToSkip, returnFieldSelector, selector, setFlags, setNumberToReturn, setNumberToSkip

Inherited Functions: buildRequest, header, messageLength, send

Enumerations

Flags

QUERY_DEFAULT = 0

Do not set any flags.

QUERY_TAILABLE_CURSOR = 2

Tailable means cursor is not closed when the last data is retrieved. Rather, the cursor marks the final object’s position. You can resume using the cursor later, from where it was located, if more data were received. Like any "latent cursor", the cursor may become invalid at some point (CursorNotFound) – for example if the final object it references were deleted.

QUERY_SLAVE_OK = 4

Allow query of replica slave. Normally these return an error except for namespace "local".

QUERY_NO_CURSOR_TIMEOUT = 16

The server normally times out idle cursors after an inactivity period (10 minutes) to prevent excess memory use. Set this option to prevent that.

QUERY_AWAIT_DATA = 32

Use with QUERY_TAILABLECURSOR. If we are at the end of the data, block for a while rather than returning no data. After a timeout period, we do return as normal.

QUERY_EXHAUST = 64

Stream the data down full blast in multiple "more" packages, on the assumption that the client will fully read all data queried. Faster when you are pulling a lot of data and know you want to pull it all down. Note: the client is not allowed to not read all the data unless it closes the connection.

QUERY_PARTIAL = 128

Get partial results from a mongos if some shards are down (instead of throwing an error).

Constructors

QueryRequest

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

Creates a QueryRequest.

The full collection name is the concatenation of the database name with the collection name, using a "." for the concatenation. For example, for the database "foo" and the collection "bar", the full collection name is "foo.bar".

Destructor

~QueryRequest virtual

virtual ~QueryRequest();

Destroys the QueryRequest.

Member Functions

fullCollectionName inline

std::string fullCollectionName() const;

Returns the <db>.<collection> used for this query.

getFlags inline

Flags getFlags() const;

Returns the flags.

getNumberToReturn inline

Int32 getNumberToReturn() const;

Returns the number of documents to return.

getNumberToSkip inline

Int32 getNumberToSkip() const;

Returns the number of documents to skip.

returnFieldSelector inline

Document & returnFieldSelector();

Returns the field selector document.

selector inline

Document & selector();

Returns the selector document.

setFlags inline

void setFlags(
    Flags flag
);

Set the flags.

setNumberToReturn inline

void setNumberToReturn(
    Int32 n
);

Sets the number of documents to return (limit).

setNumberToSkip inline

void setNumberToSkip(
    Int32 n
);

Sets the number of documents to skip.

buildRequest protected virtual

void buildRequest(
    BinaryWriter & writer
);

Securely control IoT edge devices from anywhere   Connect a Device