Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

FindAndModify add fields and upsert.

  • Loading branch information...
commit e09bd0dfad1e3b27d826a5151fd4c15864e7c415 1 parent f662081
@lanwin lanwin authored
View
16 source/MongoDB/IMongoCollection_1.cs
@@ -149,8 +149,10 @@ public interface IMongoCollection<T>
/// <param name="sort"><see cref="Document"/> containing the names of columns to sort on with the values being the
/// <see cref="IndexOrder"/></param>
/// <param name="returnNew">if set to <c>true</c> [return new].</param>
+ /// <param name="fields">The fields.</param>
+ /// <param name="upsert">if set to <c>true</c> [upsert].</param>
/// <returns>A <see cref="Document"/></returns>
- T FindAndModify(object document, object selector, object sort, bool returnNew);
+ T FindAndModify(object document, object selector, object sort, bool returnNew,object fields,bool upsert);
/// <summary>
/// Entrypoint into executing a map/reduce query against the collection.
@@ -338,5 +340,17 @@ public interface IMongoCollection<T>
/// <param name = "document">The document.</param>
/// <param name = "safemode">if set to <c>true</c> [safemode].</param>
void Save(object document, bool safemode);
+
+ /// <summary>
+ /// Executes a query and atomically applies a modifier operation to the first document returning the original document
+ /// by default.
+ /// </summary>
+ /// <param name="document">The document.</param>
+ /// <param name="spec"><see cref="Document"/> to find the document.</param>
+ /// <param name="sort"><see cref="Document"/> containing the names of columns to sort on with the values being the
+ /// <see cref="IndexOrder"/></param>
+ /// <param name="returnNew">if set to <c>true</c> [return new].</param>
+ /// <returns>A <see cref="Document"/></returns>
+ T FindAndModify(object document, object spec, object sort, bool returnNew);
}
}
View
27 source/MongoDB/MongoCollection_1.cs
@@ -182,7 +182,7 @@ public T FindOne(string javascriptWhere)
/// <returns>A <see cref="Document"/></returns>
/// <see cref="IndexOrder"/>
public T FindAndModify(object document, object spec, object sort){
- return FindAndModify(document, spec, sort, false);
+ return FindAndModify(document, spec, sort, false, null, false);
}
/// <summary>
@@ -194,7 +194,21 @@ public T FindOne(string javascriptWhere)
/// <param name="returnNew">if set to <c>true</c> [return new].</param>
/// <returns>A <see cref="Document"/></returns>
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);
+ }
+ /// <summary>
+ /// Executes a query and atomically applies a modifier operation to the first document returning the original document
+ /// by default.
+ /// </summary>
+ /// <param name="document">The document.</param>
+ /// <param name="spec"><see cref="Document"/> to find the document.</param>
+ /// <param name="sort"><see cref="Document"/> containing the names of columns to sort on with the values being the
+ /// <see cref="IndexOrder"/></param>
+ /// <param name="returnNew">if set to <c>true</c> [return new].</param>
+ /// <returns>A <see cref="Document"/></returns>
+ public T FindAndModify(object document, object spec, object sort, bool returnNew)
+ {
+ return FindAndModify(document, spec, sort, returnNew, null, false);
}
/// <summary>
@@ -206,8 +220,11 @@ public T FindOne(string javascriptWhere)
/// <param name="sort"><see cref="Document"/> containing the names of columns to sort on with the values being the
/// <see cref="IndexOrder"/></param>
/// <param name="returnNew">if set to <c>true</c> [return new].</param>
+ /// <param name="fields">The fields.</param>
+ /// <param name="upsert">if set to <c>true</c> [upsert].</param>
/// <returns>A <see cref="Document"/></returns>
- 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<FindAndModifyResult<T>>(_configuration.SerializationFactory,
View
18 source/MongoDB/Obsolete/IMongoCollection.cs
@@ -30,7 +30,7 @@ public interface IMongoCollection
/// Gets the database.
/// </summary>
/// <value>The database.</value>
- IMongoDatabase Database { get; }
+ IMongoDatabase Database { get; }
/// <summary>
/// Gets the meta data.
@@ -272,6 +272,20 @@ public interface IMongoCollection
/// </summary>
/// <param name = "document">The document.</param>
/// <param name = "safemode">if set to <c>true</c> [safemode].</param>
- void Save(Document document, bool safemode);
+ void Save(Document document, bool safemode);
+
+ /// <summary>
+ /// Executes a query and atomically applies a modifier operation to the first document returning the original document
+ /// by default.
+ /// </summary>
+ /// <param name="document">The document.</param>
+ /// <param name="spec"><see cref="Document"/> to find the document.</param>
+ /// <param name="sort"><see cref="Document"/> containing the names of columns to sort on with the values being the
+ /// <see cref="IndexOrder"/></param>
+ /// <param name="returnNew">if set to <c>true</c> [return new].</param>
+ /// <param name="fields">The fields.</param>
+ /// <param name="upsert">if set to <c>true</c> [upsert].</param>
+ /// <returns>A <see cref="Document"/></returns>
+ Document FindAndModify(Document document, Document spec, Document sort, bool returnNew, Document fields, bool upsert);
}
}
View
37 source/MongoDB/Obsolete/MongoCollection.cs
@@ -173,18 +173,35 @@ public Document FindAndModify(Document document, Document spec, bool returnNew)
}
/// <summary>
- /// Executes a query and atomically applies a modifier operation to the first document returning the original document
- /// by default.
- /// </summary>
- /// <param name = "document">The document.</param>
- /// <param name = "spec"><see cref = "Document" /> to find the document.</param>
- /// <param name = "sort"><see cref = "Document" /> containing the names of columns to sort on with the values being the
- /// <see cref = "IndexOrder" /></param>
- /// <param name = "returnNew">if set to <c>true</c> [return new].</param>
- /// <returns>A <see cref = "Document" /></returns>
+ /// Executes a query and atomically applies a modifier operation to the first document returning the original document
+ /// by default.
+ /// </summary>
+ /// <param name="document">The document.</param>
+ /// <param name="spec"><see cref="Document"/> to find the document.</param>
+ /// <param name="sort"><see cref="Document"/> containing the names of columns to sort on with the values being the
+ /// <see cref="IndexOrder"/></param>
+ /// <param name="returnNew">if set to <c>true</c> [return new].</param>
+ /// <returns>A <see cref="Document"/></returns>
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);
+ }
+
+ /// <summary>
+ /// Executes a query and atomically applies a modifier operation to the first document returning the original document
+ /// by default.
+ /// </summary>
+ /// <param name="document">The document.</param>
+ /// <param name="spec"><see cref="Document"/> to find the document.</param>
+ /// <param name="sort"><see cref="Document"/> containing the names of columns to sort on with the values being the
+ /// <see cref="IndexOrder"/></param>
+ /// <param name="returnNew">if set to <c>true</c> [return new].</param>
+ /// <param name="fields">The fields.</param>
+ /// <param name="upsert">if set to <c>true</c> [upsert].</param>
+ /// <returns>A <see cref="Document"/></returns>
+ public Document FindAndModify(Document document, Document spec, Document sort, bool returnNew, Document fields, bool upsert)
+ {
+ return _collection.FindAndModify(document, spec, sort, returnNew, fields, upsert);
}
/// <summary>

0 comments on commit e09bd0d

Please sign in to comment.
Something went wrong with that request. Please try again.