Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added get last error overload.

  • Loading branch information...
commit d8faa81aa2ebf59e2a8266a93ececc5fd473b56e 1 parent 381edbd
@atheken authored
Showing with 33 additions and 1 deletion.
  1. +1 −0  NoRM/IMongoDatabase.cs
  2. +32 −1 NoRM/MongoDatabase.cs
View
1  NoRM/IMongoDatabase.cs
@@ -23,6 +23,7 @@ public interface IMongoDatabase
IEnumerable<ProfilingInformationResponse> GetProfilingInformation();
LastErrorResponse LastError();
LastErrorResponse LastError(int verifyCount);
+ LastErrorResponse LastError(int waitCount, int waitTimeout);
SetProfileResponse SetProfileLevel(ProfileLevel level);
ValidateCollectionResponse ValidateCollection(string collectionName, bool scanData);
}
View
33 NoRM/MongoDatabase.cs
@@ -207,7 +207,8 @@ public LastErrorResponse LastError()
}
/// <summary>
- /// Number of servers that must have the last write complete before lasterror will return.
+ /// An overload of LastError requireing a number of servers
+ /// last write complete before lasterror will return.
/// </summary>
/// <param name="waitCount"></param>
/// <returns></returns>
@@ -215,5 +216,35 @@ public LastErrorResponse LastError(int waitCount)
{
return GetCollection<LastErrorResponse>("$cmd").FindOne(new { getlasterror = 1, w = waitCount });
}
+
+ /// <summary>
+ /// An overload of LastError requireing a number of servers
+ /// last write complete before lasterror will return, or the amount
+ /// of time to wait for writes to complete before returning.
+ /// </summary>
+ /// <param name="waitCount"></param>
+ /// <param name="waitTimeout"></param>
+ /// <exception cref="MongoException">If the timeout is exceeded, a MongoException is thrown.</exception>
+ /// <returns></returns>
+ public LastErrorResponse LastError(int waitCount, int waitTimeout)
+ {
+ try
+ {
+ return GetCollection<LastErrorResponse>("$cmd").FindOne(new
+ {
+ getlasterror = 1,
+ w = waitCount,
+ wtimeout = waitTimeout
+ });
+ }
+ catch (MongoException exception)
+ {
+ if(exception.Message == null)
+ {
+ exception = new MongoException("Get Last Error timed out.");
+ }
+ throw exception;
+ }
+ }
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.