Dart Documentationmongo_dartMongoUpdateMessage

MongoUpdateMessage class

class MongoUpdateMessage extends MongoMessage{
 BsonCString _collectionFullName;
 int flags;
 int numberToSkip;
 int numberToReturn;
 BsonMap _selector;
 BsonMap _document;
 MongoUpdateMessage(String collectionFullName,
           Map selector,
           document,
           this.flags
           ){
   _collectionFullName = new BsonCString(collectionFullName);
   _selector = new BsonMap(selector);
   if (document is ModifierBuilder) {
     document = document.map;
   }
   _document = new BsonMap(document);
   opcode = MongoMessage.Update;
 }
 int get messageLength{
   return 16+4+_collectionFullName.byteLength()+4+_selector.byteLength()+_document.byteLength();
 }
 BsonBinary serialize(){
   BsonBinary buffer = new BsonBinary(messageLength);
   writeMessageHeaderTo(buffer);
   buffer.writeInt(0);
   _collectionFullName.packValue(buffer);
   buffer.writeInt(flags);
   _selector.packValue(buffer);
   _document.packValue(buffer);
   buffer.offset = 0;
   return buffer;
 }
 String toString(){
   return "MongoUpdateMessage($requestId, ${_collectionFullName.value}, ${_selector.value}, ${_document.value})";
 }

}

Extends

MongoMessage > MongoUpdateMessage

Constructors

new MongoUpdateMessage(String collectionFullName, Map selector, document, int flags) #

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
MongoUpdateMessage(String collectionFullName,
         Map selector,
         document,
         this.flags
         ){
 _collectionFullName = new BsonCString(collectionFullName);
 _selector = new BsonMap(selector);
 if (document is ModifierBuilder) {
   document = document.map;
 }
 _document = new BsonMap(document);
 opcode = MongoMessage.Update;
}

Properties

int flags #

int flags

final int messageLength #

int get messageLength{
 return 16+4+_collectionFullName.byteLength()+4+_selector.byteLength()+_document.byteLength();
}

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(0);
 _collectionFullName.packValue(buffer);
 buffer.writeInt(flags);
 _selector.packValue(buffer);
 _document.packValue(buffer);
 buffer.offset = 0;
 return buffer;
}

String toString() #

Returns a string representation of this object.

docs inherited from Object
String toString(){
 return "MongoUpdateMessage($requestId, ${_collectionFullName.value}, ${_selector.value}, ${_document.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');
   }
}