1//
2// InsertRequest.cpp
3//
4// Library: MongoDB
5// Package: MongoDB
6// Module: InsertRequest
7//
8// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
9// and Contributors.
10//
11// SPDX-License-Identifier: BSL-1.0
12//
13
14
15#include "Poco/MongoDB/InsertRequest.h"
16
17
18namespace Poco {
19namespace MongoDB {
20
21
22InsertRequest::InsertRequest(const std::string& collectionName, Flags flags):
23 RequestMessage(MessageHeader::OP_INSERT),
24 _flags(flags),
25 _fullCollectionName(collectionName)
26{
27}
28
29
30InsertRequest::~InsertRequest()
31{
32}
33
34
35void InsertRequest::buildRequest(BinaryWriter& writer)
36{
37 poco_assert (!_documents.empty());
38
39 writer << _flags;
40 BSONWriter bsonWriter(writer);
41 bsonWriter.writeCString(_fullCollectionName);
42 for (Document::Vector::iterator it = _documents.begin(); it != _documents.end(); ++it)
43 {
44 bsonWriter.write(*it);
45 }
46}
47
48
49} } // namespace Poco::MongoDB
50