Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

More find and modify improvments.

commit 6397a0f032f24227894afa6ec37e92dd18dd0b3f 1 parent e09bd0d
@lanwin lanwin authored
View
5 source/MongoDB/IMongoCollection_1.cs
@@ -148,11 +148,12 @@ public interface IMongoCollection<T>
/// <param name="selector">The selector.</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="remove">if set to <c>true</c> [remove].</param>
+ /// <param name="returnNew">if set to <c>true</c> [return new].</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,object fields,bool upsert);
+ T FindAndModify(object document, object selector, object sort, object fields, bool remove, bool returnNew, bool upsert);
/// <summary>
/// Entrypoint into executing a map/reduce query against the collection.
View
25 source/MongoDB/MongoCollection_1.cs
@@ -181,8 +181,9 @@ public T FindOne(string javascriptWhere)
/// <param name="sort"><see cref="Document"/> containing the names of columns to sort on with the values being the</param>
/// <returns>A <see cref="Document"/></returns>
/// <see cref="IndexOrder"/>
- public T FindAndModify(object document, object spec, object sort){
- return FindAndModify(document, spec, sort, false, null, false);
+ public T FindAndModify(object document, object spec, object sort)
+ {
+ return FindAndModify(document, spec, sort, null, false, false, false);
}
/// <summary>
@@ -193,8 +194,9 @@ public T FindOne(string javascriptWhere)
/// <param name="spec"><see cref="Document"/> to find the document.</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, bool returnNew){
- return FindAndModify(document, spec, new Document(), returnNew,null,false);
+ public T FindAndModify(object document, object spec, bool returnNew)
+ {
+ return FindAndModify(document, spec, null, null, false, returnNew, false);
}
/// <summary>
/// Executes a query and atomically applies a modifier operation to the first document returning the original document
@@ -208,7 +210,7 @@ public T FindOne(string javascriptWhere)
/// <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);
+ return FindAndModify(document, spec, sort, null, false, returnNew, false);
}
/// <summary>
@@ -219,11 +221,12 @@ public T FindAndModify(object document, object spec, object sort, bool returnNew
/// <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="remove">if set to <c>true</c> [remove].</param>
+ /// <param name="returnNew">if set to <c>true</c> [return new].</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,object fields,bool upsert)
+ public T FindAndModify(object document, object spec, object sort, object fields, bool remove, bool returnNew, bool upsert)
{
try
{
@@ -232,12 +235,16 @@ public T FindAndModify(object document, object spec, object sort, bool returnNew
{"findandmodify", Name},
{"query", spec},
{"update", EnsureUpdateDocument(document)},
- {"sort", sort},
{"new", returnNew},
- {"fields", fields},
+ {"remove", remove},
{"upsert", upsert}
};
+ if(sort != null)
+ command.Add("sort", sort);
+ if(fields != null)
+ command.Add("fields", fields);
+
var response = _connection.SendCommand<FindAndModifyResult<T>>(_configuration.SerializationFactory,
DatabaseName,
typeof(T),
View
31 source/MongoDB/Obsolete/IMongoCollection.cs
@@ -125,7 +125,22 @@ public interface IMongoCollection
/// <param name="returnNew">if set to <c>true</c> [return new].</param>
/// <returns>A <see cref="Document"/></returns>
Document FindAndModify(Document document, Document selector, Document sort, 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="fields">The fields.</param>
+ /// <param name="remove">if set to <c>true</c> [remove].</param>
+ /// <param name="returnNew">if set to <c>true</c> [return new].</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, Document fields, bool remove, bool returnNew, bool upsert);
+
/// <summary>
/// Maps the reduce.
/// </summary>
@@ -273,19 +288,5 @@ public interface IMongoCollection
/// <param name = "document">The document.</param>
/// <param name = "safemode">if set to <c>true</c> [safemode].</param>
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
9 source/MongoDB/Obsolete/MongoCollection.cs
@@ -184,7 +184,7 @@ public Document FindAndModify(Document document, Document spec, bool returnNew)
/// <returns>A <see cref="Document"/></returns>
public Document FindAndModify(Document document, Document spec, Document sort, bool returnNew)
{
- return _collection.FindAndModify(document, spec, sort, returnNew, null, false);
+ return _collection.FindAndModify(document, spec, sort, null, false, returnNew, false);
}
/// <summary>
@@ -195,13 +195,14 @@ public Document FindAndModify(Document document, Document spec, Document sort, b
/// <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="remove">if set to <c>true</c> [remove].</param>
+ /// <param name="returnNew">if set to <c>true</c> [return new].</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)
+ public Document FindAndModify(Document document, Document spec, Document sort, Document fields, bool remove, bool returnNew, bool upsert)
{
- return _collection.FindAndModify(document, spec, sort, returnNew, fields, upsert);
+ return _collection.FindAndModify(document, spec, sort, fields, remove, returnNew, upsert);
}
/// <summary>
Please sign in to comment.
Something went wrong with that request. Please try again.