Dart Documentationmongo_dartMongoQueryMessage

MongoQueryMessage class

class MongoQueryMessage extends MongoMessage{
static final OPTS_NONE = 0;
static final OPTS_TAILABLE_CURSOR = 2;
static final OPTS_SLAVE = 4;
static final OPTS_OPLOG_REPLY = 8;
static final OPTS_NO_CURSOR_TIMEOUT = 16;
static final OPTS_AWAIT_DATA = 32;
static final OPTS_EXHAUST = 64;


 BsonCString _collectionFullName;
 int flags;
 int numberToSkip;
 int numberToReturn;
 BsonMap _query;
 BsonMap _fields;
 BsonCString get collectionNameBson => _collectionFullName;
 MongoQueryMessage(String collectionFullName,
           this.flags,
           this.numberToSkip,
           this.numberToReturn,
           Map query,
           Map fields){
   _collectionFullName = new BsonCString(collectionFullName);
   _query = new BsonMap(query);
   if (fields != null){
     _fields = new BsonMap(fields);
   }
   opcode = MongoMessage.Query;
 }
 int get messageLength{
   int result = 16+4+_collectionFullName.byteLength()+4+4+_query.byteLength();
   if (_fields != null){
     result += _fields.byteLength();
   }
   return result;
 }
 BsonBinary serialize(){
   BsonBinary buffer = new BsonBinary(messageLength);
   writeMessageHeaderTo(buffer);
   buffer.writeInt(flags);
   _collectionFullName.packValue(buffer);
   buffer.writeInt(numberToSkip);
   buffer.writeInt(numberToReturn);
   _query.packValue(buffer);
   if (_fields != null){
     _fields.packValue(buffer);
   }
   buffer.offset = 0;
   return buffer;
 }
 String toString(){
   return "MongoQueryMessage($requestId, ${_collectionFullName.value},numberToReturn:$numberToReturn, ${_query.value})";
 }
}

Extends

MongoMessage > MongoQueryMessage

Subclasses

DbCommand

Static Properties

final OPTS_AWAIT_DATA #

static final OPTS_AWAIT_DATA = 32

final OPTS_EXHAUST #

static final OPTS_EXHAUST = 64

final OPTS_NO_CURSOR_TIMEOUT #

static final OPTS_NO_CURSOR_TIMEOUT = 16

final OPTS_NONE #

static final OPTS_NONE = 0

final OPTS_OPLOG_REPLY #

static final OPTS_OPLOG_REPLY = 8

final OPTS_SLAVE #

static final OPTS_SLAVE = 4

final OPTS_TAILABLE_CURSOR #

static final OPTS_TAILABLE_CURSOR = 2

Constructors

new MongoQueryMessage(String collectionFullName, int flags, int numberToSkip, int numberToReturn, Map query, Map fields) #

Creates a new Object instance.

Object instances have no meaningful state, and are only useful through their identity. An Object instance is equal to itself only.

docs inherited from Object
MongoQueryMessage(String collectionFullName,
         this.flags,
         this.numberToSkip,
         this.numberToReturn,
         Map query,
         Map fields){
 _collectionFullName = new BsonCString(collectionFullName);
 _query = new BsonMap(query);
 if (fields != null){
   _fields = new BsonMap(fields);
 }
 opcode = MongoMessage.Query;
}

Properties

final BsonCString collectionNameBson #

BsonCString get collectionNameBson => _collectionFullName;

int flags #

int flags

final int messageLength #

int get messageLength{
 int result = 16+4+_collectionFullName.byteLength()+4+4+_query.byteLength();
 if (_fields != null){
   result += _fields.byteLength();
 }
 return result;
}

int numberToReturn #

int numberToReturn

int numberToSkip #

int numberToSkip

int opcode #

inherited from MongoMessage
int opcode = MongoMessage.Reply

final int requestId #

inherited from MongoMessage
int get requestId{
 if (_requestId == null){
   _requestId = _Statics.nextRequestId;
 }
 return _requestId;
}

int responseTo #

inherited from MongoMessage
int responseTo

Methods

MongoMessage deserialize(BsonBinary buffer) #

inherited from MongoMessage
MongoMessage deserialize(BsonBinary buffer){
 throw new MongoDartError('Must be implemented');
}

dynamic readMessageHeaderFrom(BsonBinary buffer) #

inherited from MongoMessage
readMessageHeaderFrom(BsonBinary buffer)
{
   _messageLength = buffer.readInt32();
   _requestId = buffer.readInt32();
   responseTo = buffer.readInt32();
   int opcodeFromWire = buffer.readInt32();
   if (opcodeFromWire != opcode)
   {
       throw new MongoDartError('Expected $opcode in Message header. Got $opcodeFromWire');
   }
}

BsonBinary serialize() #

BsonBinary serialize(){
 BsonBinary buffer = new BsonBinary(messageLength);
 writeMessageHeaderTo(buffer);
 buffer.writeInt(flags);
 _collectionFullName.packValue(buffer);
 buffer.writeInt(numberToSkip);
 buffer.writeInt(numberToReturn);
 _query.packValue(buffer);
 if (_fields != null){
   _fields.packValue(buffer);
 }
 buffer.offset = 0;
 return buffer;
}

String toString() #

Returns a string representation of this object.

docs inherited from Object
String toString(){
 return "MongoQueryMessage($requestId, ${_collectionFullName.value},numberToReturn:$numberToReturn, ${_query.value})";
}

dynamic writeMessageHeaderTo(BsonBinary buffer) #

inherited from MongoMessage
writeMessageHeaderTo(BsonBinary buffer)
{
   buffer.writeInt(messageLength); // messageLength will be backpatched later
   buffer.writeInt(requestId);
   buffer.writeInt(0); // responseTo not used in requests sent by client
   buffer.writeInt(opcode);
   if (messageLength < 0){
     throw new MongoDartError('Error in message length');
   }
}