Skip to content

Commit

Permalink
Fix DatabaseJavascript failing test.
Browse files Browse the repository at this point in the history
  • Loading branch information
lanwin committed May 20, 2010
1 parent d3b6d1d commit 81be991
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions source/MongoDB/DatabaseJavascript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public Document this[String name]
/// </exception>
public void Add(Document item)
{
if(_collection.FindOne(new Document().Add("_id", item["_id"])) != null)
if(_collection.FindOne(new Document("_id", item["_id"])) != null)
throw new ArgumentException(String.Format("Function {0} already exists in the database.", item["_id"]));
_collection.Insert(item);
}
Expand Down Expand Up @@ -91,12 +91,14 @@ public bool Contains(Document item)
/// </exception>
public void CopyTo(Document[] array, int arrayIndex)
{
var query = new Document("$orderby", new Document("_id", 1));
var index = arrayIndex;
foreach(var document in _collection.Find(query, array.Length - 1, arrayIndex).Documents)
using(var cursor = _collection.FindAll().Limit(array.Length - 1).Skip(arrayIndex).Sort("_id"))
{
array[index] = document;
index++;
var index = arrayIndex;
foreach(var document in cursor.Documents)
{
array[index] = document;
index++;
}
}
}

Expand Down

0 comments on commit 81be991

Please sign in to comment.