protected byte[] GenerateBody() { //http://www.mongodb.org/display/DOCS/Mongo+Wire+Protocol#MongoWireProtocol-OPQUERY //int32 opts; // query options. //cstring fullCollectionName; // "dbname.collectionname" //int32 numberToSkip; // number of documents to skip when returning results //int32 numberToReturn; // number of documents to return in the first OP_REPLY //BSON query; // query object. See below for details. //BSON returnFieldSelector; // OPTIONAL : selector indicating the fields to return. See below for details. using (var stream = new MemoryStream()) { using (var writer = new BodyWriter(stream)) { writer.Write((int)QueryCommandOptions.None); writer.Write(NodeName + ".$cmd"); writer.WriteTerminator(); writer.Write(0); writer.Write(-1); writer.WriteSelector(Command); return(stream.ToArray()); } } }
protected byte[] GenerateBody() { //http://www.mongodb.org/display/DOCS/Mongo+Wire+Protocol#MongoWireProtocol-OPDELETE //int32 ZERO; // 0 - reserved for future use //cstring fullCollectionName; // "dbname.collectionname" //int32 ZERO; // 0 - reserved for future use //BSON selector; // BSON document that represent the query used // to select the documents to be removed. The // selector will contain one or more elements, // all of which must match for a document to be //removed from the collection using (var stream = new MemoryStream()) { using (var writer = new BodyWriter(stream)) { writer.Write(0); writer.Write(FullCollectionName); writer.Write(0); writer.WriteTerminator(); writer.WriteSelector(Selector ?? new object()); return(stream.ToArray()); } } }
protected byte[] GenerateBody() { //http://www.mongodb.org/display/DOCS/Mongo+Wire+Protocol#MongoWireProtocol-OPQUERY //int32 opts; // query options //cstring fullCollectionName; // "dbname.collectionname" //int32 numberToSkip; // number of documents to skip when returning results //int32 numberToReturn; // number of documents to return in the first OP_REPLY //BSON query; // query object. See below for details. //BSON returnFieldSelector; // OPTIONAL : selector indicating the fields to return. See below for details. using (var stream = new MemoryStream()) { using (var writer = new BodyWriter(stream)) { //Number of docs to return: // 0 => the server will use the default return size; // -x => If the number is negative, then the database will return that number and close the cursor. // 1 => the server will treat it as -1 (closing the cursor automatically) var numOfDocsToReturn = NumberOfDocumentsToReturn ?? 0; if (numOfDocsToReturn > 0) { numOfDocsToReturn = numOfDocsToReturn * -1; } writer.Write((int)Options); writer.Write(FullCollectionName); writer.WriteTerminator(); writer.Write(NumberOfDocumentsToSkip ?? 0); writer.Write(numOfDocsToReturn); writer.WriteSelector(QuerySelector ?? new object()); if (DocumentSchema != null) { writer.WriteDocument(DocumentSchema); } return(stream.ToArray()); } } }
protected byte[] GenerateBody() { //http://www.mongodb.org/display/DOCS/Mongo+Wire+Protocol#MongoWireProtocol-OPUPDATE //int32 ZERO; // 0 - reserved for future use //cstring fullCollectionName; // "dbname.collectionname" //int32 flags; // bit vector. see below //BSON selector; // the query to select the document //BSON document; // the document data to update with or insert using (var stream = new MemoryStream()) { using (var writer = new BodyWriter(stream)) { writer.Write(0); writer.Write(FullCollectionName); writer.WriteTerminator(); writer.Write((int)Mode); writer.WriteSelector(QuerySelector ?? new object()); writer.WriteDocument(Document); return(stream.ToArray()); } } }