diff --git a/source/MongoDB/IMongoCollection_1.cs b/source/MongoDB/IMongoCollection_1.cs index 9ddfa888..83675de8 100644 --- a/source/MongoDB/IMongoCollection_1.cs +++ b/source/MongoDB/IMongoCollection_1.cs @@ -149,8 +149,10 @@ public interface IMongoCollection /// containing the names of columns to sort on with the values being the /// /// if set to true [return new]. + /// The fields. + /// if set to true [upsert]. /// A - T FindAndModify(object document, object selector, object sort, bool returnNew); + T FindAndModify(object document, object selector, object sort, bool returnNew,object fields,bool upsert); /// /// Entrypoint into executing a map/reduce query against the collection. @@ -338,5 +340,17 @@ public interface IMongoCollection /// The document. /// if set to true [safemode]. void Save(object document, bool safemode); + + /// + /// Executes a query and atomically applies a modifier operation to the first document returning the original document + /// by default. + /// + /// The document. + /// to find the document. + /// containing the names of columns to sort on with the values being the + /// + /// if set to true [return new]. + /// A + T FindAndModify(object document, object spec, object sort, bool returnNew); } } \ No newline at end of file diff --git a/source/MongoDB/MongoCollection_1.cs b/source/MongoDB/MongoCollection_1.cs index 85c924b4..09d8e068 100644 --- a/source/MongoDB/MongoCollection_1.cs +++ b/source/MongoDB/MongoCollection_1.cs @@ -182,7 +182,7 @@ public T FindOne(string javascriptWhere) /// A /// public T FindAndModify(object document, object spec, object sort){ - return FindAndModify(document, spec, sort, false); + return FindAndModify(document, spec, sort, false, null, false); } /// @@ -194,7 +194,21 @@ public T FindOne(string javascriptWhere) /// if set to true [return new]. /// A public T FindAndModify(object document, object spec, bool returnNew){ - return FindAndModify(document, spec, new Document(), returnNew); + return FindAndModify(document, spec, new Document(), returnNew,null,false); + } + /// + /// Executes a query and atomically applies a modifier operation to the first document returning the original document + /// by default. + /// + /// The document. + /// to find the document. + /// containing the names of columns to sort on with the values being the + /// + /// if set to true [return new]. + /// A + public T FindAndModify(object document, object spec, object sort, bool returnNew) + { + return FindAndModify(document, spec, sort, returnNew, null, false); } /// @@ -206,8 +220,11 @@ public T FindOne(string javascriptWhere) /// containing the names of columns to sort on with the values being the /// /// if set to true [return new]. + /// The fields. + /// if set to true [upsert]. /// A - public T FindAndModify(object document, object spec, object sort, bool returnNew){ + public T FindAndModify(object document, object spec, object sort, bool returnNew,object fields,bool upsert) + { try { var command = new Document @@ -216,7 +233,9 @@ public T FindOne(string javascriptWhere) {"query", spec}, {"update", EnsureUpdateDocument(document)}, {"sort", sort}, - {"new", returnNew} + {"new", returnNew}, + {"fields", fields}, + {"upsert", upsert} }; var response = _connection.SendCommand>(_configuration.SerializationFactory, diff --git a/source/MongoDB/Obsolete/IMongoCollection.cs b/source/MongoDB/Obsolete/IMongoCollection.cs index 1f10c20f..f7744319 100644 --- a/source/MongoDB/Obsolete/IMongoCollection.cs +++ b/source/MongoDB/Obsolete/IMongoCollection.cs @@ -30,7 +30,7 @@ public interface IMongoCollection /// Gets the database. /// /// The database. - IMongoDatabase Database { get; } + IMongoDatabase Database { get; } /// /// Gets the meta data. @@ -272,6 +272,20 @@ public interface IMongoCollection /// /// The document. /// if set to true [safemode]. - void Save(Document document, bool safemode); + void Save(Document document, bool safemode); + + /// + /// Executes a query and atomically applies a modifier operation to the first document returning the original document + /// by default. + /// + /// The document. + /// to find the document. + /// containing the names of columns to sort on with the values being the + /// + /// if set to true [return new]. + /// The fields. + /// if set to true [upsert]. + /// A + Document FindAndModify(Document document, Document spec, Document sort, bool returnNew, Document fields, bool upsert); } } \ No newline at end of file diff --git a/source/MongoDB/Obsolete/MongoCollection.cs b/source/MongoDB/Obsolete/MongoCollection.cs index 69875435..2626a95a 100644 --- a/source/MongoDB/Obsolete/MongoCollection.cs +++ b/source/MongoDB/Obsolete/MongoCollection.cs @@ -173,18 +173,35 @@ public Document FindAndModify(Document document, Document spec, bool returnNew) } /// - /// Executes a query and atomically applies a modifier operation to the first document returning the original document - /// by default. - /// - /// The document. - /// to find the document. - /// containing the names of columns to sort on with the values being the - /// - /// if set to true [return new]. - /// A + /// Executes a query and atomically applies a modifier operation to the first document returning the original document + /// by default. + /// + /// The document. + /// to find the document. + /// containing the names of columns to sort on with the values being the + /// + /// if set to true [return new]. + /// A public Document FindAndModify(Document document, Document spec, Document sort, bool returnNew) { - return _collection.FindAndModify(document, spec, sort, returnNew); + return _collection.FindAndModify(document, spec, sort, returnNew, null, false); + } + + /// + /// Executes a query and atomically applies a modifier operation to the first document returning the original document + /// by default. + /// + /// The document. + /// to find the document. + /// containing the names of columns to sort on with the values being the + /// + /// if set to true [return new]. + /// The fields. + /// if set to true [upsert]. + /// A + public Document FindAndModify(Document document, Document spec, Document sort, bool returnNew, Document fields, bool upsert) + { + return _collection.FindAndModify(document, spec, sort, returnNew, fields, upsert); } ///