diff options
author | Judah Schvimer <judah@mongodb.com> | 2017-05-19 10:00:45 -0400 |
---|---|---|
committer | Judah Schvimer <judah@mongodb.com> | 2017-05-19 10:00:45 -0400 |
commit | a966f53f267c8f37ccbbc6008518befe14599582 (patch) | |
tree | e6d5e393c1f9fd14ac06a8d600fd72803bff0a9e /src/mongo/db/repl/storage_interface.h | |
parent | 72000a222189cd0768d7213a9835b212dd2507b5 (diff) | |
download | mongo-a966f53f267c8f37ccbbc6008518befe14599582.tar.gz |
SERVER-29254 add findSingleton and putSingleton methods to StorageInterface
Diffstat (limited to 'src/mongo/db/repl/storage_interface.h')
-rw-r--r-- | src/mongo/db/repl/storage_interface.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/mongo/db/repl/storage_interface.h b/src/mongo/db/repl/storage_interface.h index 12f0d25507f..bf5a101b6a7 100644 --- a/src/mongo/db/repl/storage_interface.h +++ b/src/mongo/db/repl/storage_interface.h @@ -270,6 +270,27 @@ public: std::size_t limit) = 0; /** + * Finds a singleton document in a collection. Returns 'CollectionIsEmpty' if the collection + * is empty or 'TooManyMatchingDocuments' if it is not a singleton collection. + */ + virtual StatusWith<BSONObj> findSingleton(OperationContext* opCtx, + const NamespaceString& nss) = 0; + + /** + * Updates a singleton document in a collection. Upserts the document if it does not exist. If + * the document is upserted and no '_id' is provided, one will be generated. + * If the collection has more than 1 document, the update will only be performed on the first + * one found. + * Returns 'NamespaceNotFound' if the collection does not exist. This does not implicitly + * create the collection so that the caller can create the collection with any collection + * options they want (ex: capped, temp, collation, etc.). + */ + virtual Status putSingleton(OperationContext* opCtx, + const NamespaceString& nss, + const BSONObj& update) = 0; + + + /** * Finds a single document in the collection referenced by the specified _id. * * Not supported on collections with a default collation. |