BSONObj ChunkType::toBSON() const { BSONObjBuilder builder; if (_name) builder.append(name.name(), getName()); if (_ns) builder.append(ns.name(), getNS()); if (_min) builder.append(min.name(), getMin()); if (_max) builder.append(max.name(), getMax()); if (_shard) builder.append(shard.name(), getShard()); if (_version) { // For now, write both the deprecated *and* the new fields _version->addToBSON(builder, version()); _version->addToBSON(builder, DEPRECATED_lastmod()); } if (_jumbo) builder.append(jumbo.name(), getJumbo()); return builder.obj(); }
BSONObj ChunkType::toConfigBSON() const { BSONObjBuilder builder; if (_nss && _min) builder.append(name.name(), getName()); if (_nss) builder.append(ns.name(), getNS().ns()); if (_min) builder.append(min.name(), getMin()); if (_max) builder.append(max.name(), getMax()); if (_shard) builder.append(shard.name(), getShard().toString()); if (_version) _version->appendForChunk(&builder); if (_jumbo) builder.append(jumbo.name(), getJumbo()); return builder.obj(); }