Permalink
Browse files

Changed MongoCollection back to Collection for backward compatibility.

  • Loading branch information...
1 parent b35f5a5 commit 3f2e4b440287a13a3bd20ccec540fae0de456acd @samus committed Mar 21, 2010
@@ -26,7 +26,7 @@ public static void Main (string[] args)
Mongo m = new Mongo();
m.Connect();
- MongoDatabase db = m["benchmark"];
+ Database db = m["benchmark"];
db.MetaData.DropDatabase();
Console.WriteLine("Starting Tests");
@@ -104,7 +104,7 @@ public static void Main (string[] args)
large.Add("harvested_words", harvestedWords);
}
#region Insert Tests
- static void RunInsertTest(string name, MongoDatabase db, string col, Document doc, bool index, bool bulk){
+ static void RunInsertTest(string name, Database db, string col, Document doc, bool index, bool bulk){
TimeSpan lowest = TimeSpan.MaxValue;
for(int i = 0; i < trials; i++){
SetupInsert(db,"col",index);
@@ -115,7 +115,7 @@ public static void Main (string[] args)
Console.Out.WriteLine(String.Format("{0}{1} {2}", name + new string('.', 55 - name.Length), opsSec, lowest));
}
- static void SetupInsert(MongoDatabase db, string col, bool index){
+ static void SetupInsert(Database db, string col, bool index){
try{
db.MetaData.DropCollection(col);
if(index){
@@ -127,7 +127,7 @@ public static void Main (string[] args)
}
}
- static TimeSpan TimeInsert(MongoDatabase db, string col, Document doc, bool bulk){
+ static TimeSpan TimeInsert(Database db, string col, Document doc, bool bulk){
DateTime start = DateTime.Now;
if(bulk){
DoBulkInsert(db,col,doc, batchSize);
@@ -139,7 +139,7 @@ public static void Main (string[] args)
return t;
}
- static void DoInsert(MongoDatabase db, string col, Document doc){
+ static void DoInsert(Database db, string col, Document doc){
for(int i = 0; i < perTrial; i++){
Document ins = new Document();
doc.CopyTo(ins);
@@ -148,7 +148,7 @@ public static void Main (string[] args)
}
}
- static void DoBulkInsert(MongoDatabase db, string col, Document doc, int size){
+ static void DoBulkInsert(Database db, string col, Document doc, int size){
for(int i = 0; i < perTrial / size; i++){
Document[] docs = new Document[size];
for(int f = 0; f < docs.Length; f++){
@@ -224,7 +224,7 @@ public static void Main (string[] args)
}
#region Find Tests
- static void RunFindTest(string name, MongoDatabase db, string col, Document spec, bool range){
+ static void RunFindTest(string name, Database db, string col, Document spec, bool range){
TimeSpan lowest = TimeSpan.MaxValue;
for(int i = 0; i < trials; i++){
TimeSpan ret = TimeFind(db, col, spec, range);
@@ -234,7 +234,7 @@ public static void Main (string[] args)
Console.Out.WriteLine(String.Format("{0}{1} {2}", name + new string('.', 55 - name.Length), opsSec, lowest));
}
- static TimeSpan TimeFind(MongoDatabase db, string col,Document psec, bool range){
+ static TimeSpan TimeFind(Database db, string col,Document psec, bool range){
DateTime start = DateTime.Now;
if(range){
DoFindOne(db,col,psec);
@@ -246,13 +246,13 @@ public static void Main (string[] args)
return t;
}
- static void DoFindOne(MongoDatabase db, string col, Document spec){
+ static void DoFindOne(Database db, string col, Document spec){
for(int i = 0; i < perTrial; i++){
db[col].FindOne(spec);
}
}
- static void DoFind(MongoDatabase db, string col, Document spec){
+ static void DoFind(Database db, string col, Document spec){
for(int i = 0; i < perTrial; i++){
ICursor cur = db[col].Find(spec);
foreach(Document d in cur.Documents){
@@ -92,7 +92,7 @@ public string FileName
if(gridFile.Exists(filename)) this.LoadFileData();
}
- public GridFileInfo(MongoDatabase db, string filename){
+ public GridFileInfo(Database db, string filename){
this.db = db;
this.bucket = "fs";
this.gridFile = new GridFile(db);
@@ -9,7 +9,7 @@ namespace MongoDB.Driver
[TestFixture]
public class TestCollectionMetaData : MongoTestBase
{
- MongoDatabase adminDb;
+ Database adminDb;
public override string TestCollections {
get {
@@ -29,7 +29,7 @@ public void TestDefaults()
Mongo m = new Mongo(connectionString);
bool thrown = false;
try{
- MongoDatabase db = m["admin"];
+ Database db = m["admin"];
db["$cmd"].FindOne(new Document().Add("listDatabases", 1.0));
}catch(MongoCommException){
thrown = true;
@@ -12,9 +12,9 @@ namespace MongoDB.Driver
/// <summary>
/// <see cref = "IMongoCollection" />
/// </summary>
- public class MongoCollection : IMongoCollection
+ public class Collection : IMongoCollection
{
- MongoCollection<Document> _collection;
+ Collection<Document> _collection;
public string Database {
get { return _collection.DatabaseName; }
@@ -44,9 +44,9 @@ public class MongoCollection : IMongoCollection
/// <param name="connection">The connection.</param>
/// <param name="databaseName">Name of the database.</param>
/// <param name="name">The name.</param>
- public MongoCollection(Connection connection, string databaseName, string name)
+ public Collection(Connection connection, string databaseName, string name)
{
- _collection = new MongoCollection<Document>(connection, databaseName, name);
+ _collection = new Collection<Document>(connection, databaseName, name);
}
public Document FindOne(Document spec){
@@ -12,12 +12,12 @@ public class CollectionMetaData
{
private string fullName;
private string name;
- private MongoDatabase db;
+ private Database db;
public CollectionMetaData (string dbName, string name, Connection conn){
this.fullName = dbName + "." + name;
this.name = name;
- this.db = new MongoDatabase (conn, dbName);
+ this.db = new Database (conn, dbName);
}
private Document options = null;
@@ -9,7 +9,7 @@
namespace MongoDB.Driver
{
- public class MongoDatabase : IMongoDatabase
+ public class Database : IMongoDatabase
{
private readonly Connection _connection;
private DatabaseJavascript _javascript;
@@ -20,7 +20,7 @@ public class MongoDatabase : IMongoDatabase
/// </summary>
/// <param name="connectionString">The connection string.</param>
/// <param name="name">The name.</param>
- public MongoDatabase(string connectionString, String name)
+ public Database(string connectionString, String name)
:this(ConnectionFactory.GetConnection(connectionString),name)
{
if(name == null)
@@ -32,7 +32,7 @@ public MongoDatabase(string connectionString, String name)
/// </summary>
/// <param name="connection">The conn.</param>
/// <param name="name">The name.</param>
- public MongoDatabase(Connection connection, String name){
+ public Database(Connection connection, String name){
//Todo: should be internal
Name = name;
_connection = connection;
@@ -87,7 +87,7 @@ public MongoDatabase(string connectionString, String name)
/// <param name="name">The name.</param>
/// <returns></returns>
public IMongoCollection GetCollection(String name){
- return new MongoCollection(_connection, Name, name);
+ return new Collection(_connection, Name, name);
}
/// <summary>
@@ -97,7 +97,7 @@ public MongoDatabase(string connectionString, String name)
/// <param name="name">The name.</param>
/// <returns></returns>
public IMongoCollection<T> GetCollection<T>(String name) where T : class{
- return new MongoCollection<T>(_connection, Name, name);
+ return new Collection<T>(_connection, Name, name);
}
/// <summary>
@@ -160,8 +160,8 @@ public MongoDatabase(string connectionString, String name)
/// </summary>
/// <param name="sisterDatabaseName">Name of the sister database.</param>
/// <returns></returns>
- public MongoDatabase GetSisterDatabase(string sisterDatabaseName){
- return new MongoDatabase(_connection, sisterDatabaseName);
+ public Database GetSisterDatabase(string sisterDatabaseName){
+ return new Database(_connection, sisterDatabaseName);
}
/// <summary>
@@ -10,7 +10,7 @@ public class DatabaseJavascript : ICollection<Document>
{
private IMongoCollection js;
- internal DatabaseJavascript (MongoDatabase db){
+ internal DatabaseJavascript (Database db){
this.js = db["system.js"];
//Needed for some versions of the db to retrieve the functions.
js.MetaData.CreateIndex(new Document().Add("_id", 1), true);
@@ -10,12 +10,12 @@ public class DatabaseMetaData
{
private Connection connection;
private string name;
- private MongoDatabase db;
+ private Database db;
public DatabaseMetaData(string name, Connection conn){
this.connection = conn;
this.name = name;
- this.db = new MongoDatabase(conn, name);
+ this.db = new Database(conn, name);
}
public IMongoCollection CreateCollection(String name){
@@ -27,11 +27,11 @@ public IMongoCollection CreateCollection(String name, Document options)
Document cmd = new Document();
cmd.Add("create", name).Merge(options);
db.SendCommand(cmd);
- return new MongoCollection(connection, this.name, name);
+ return new Collection(connection, this.name, name);
}
- public Boolean DropCollection(MongoCollection col)
+ public Boolean DropCollection(Collection col)
{
return this.DropCollection(col.Name);
}
@@ -48,7 +48,7 @@ public Boolean DropCollection(MongoCollection col)
public void AddUser(string username, string password){
IMongoCollection users = db["system.users"];
- string pwd = MongoDatabase.Hash(username + ":mongo:" + password);
+ string pwd = Database.Hash(username + ":mongo:" + password);
Document user = new Document().Add("user", username).Add("pwd", pwd);
if (FindUser(username) != null){
Oops, something went wrong.

0 comments on commit 3f2e4b4

Please sign in to comment.