HasDatabase() public method

Returns a bool indicating whether or not the database exists.
public HasDatabase ( string databaseName ) : bool
databaseName string
return bool
示例#1
0
 public void Setup()
 {
     client = new CouchClient(host, port, username, password);
     if (!client.HasDatabase(baseDatabase))
     {
         client.CreateDatabase(baseDatabase);
     }
     if (!client.HasDatabase(replicateDatabase))
     {
         client.CreateDatabase(replicateDatabase);
     }
 }
示例#2
0
		public static void ToCouchDb(RuntimeStorage intent){

			CouchClient client = new CouchClient ();
			if (!client.HasDatabase (DATABASE))
				client.CreateDatabase (DATABASE);

			CouchDatabase db = client.GetDatabase(DATABASE);
			CouchDbIntentData dbIntent;
			try{

				Document doc = db.GetDocument(intent.filename);
				dbIntent = new CouchDbIntentData();
				dbIntent.data = intent.data;

				Document<CouchDbIntentData> tosave = new Document<CouchDbIntentData>(dbIntent);
				tosave.Id = doc.Id;
				tosave.Rev = doc.Rev;
				db.SaveDocument(tosave);

			}catch{

				dbIntent = new CouchDbIntentData ();
				dbIntent.data = intent.data;
				Document<CouchDbIntentData> tosave = new Document<CouchDbIntentData>(dbIntent);
				tosave.Id = intent.filename;

				db.CreateDocument (tosave);
			}
		}
示例#3
0
 public void Setup()
 {
     client = new CouchClient(host, port, username, password, false,AuthenticationType.Cookie);
     if (!client.HasDatabase(baseDatabase))
     {
         client.CreateDatabase(baseDatabase);
     }
     if (!client.HasDatabase(replicateDatabase))
     {
         client.CreateDatabase(replicateDatabase);
     }
 }
示例#4
0
文件: Program.cs 项目: Slesa/Poseidon
        static void Main(string[] args)
        {

            var ccAdmin = new CouchClient("localhost", 5984, null, null, false, AuthenticationType.Cookie);

            var dbName = "firsttry";
            if (!ccAdmin.HasDatabase(dbName))
            {
                ccAdmin.CreateDatabase(dbName);
            }


            var table = new Table {Id = "5"};
            table.Families.AddRange(Family.CreateFamilies());
            table.FamilyGroups.AddRange(FamilyGroup.CreateFamilyGroups());
            var doc = new Document<Table>(table);

            var db = ccAdmin.GetDatabase(dbName);
            db.SetDefaultDesignDoc("docs"); 

            db.SaveDocument(doc);
        }
示例#5
0
 public bool Isinitialised()
 {
     var client = new CouchClient("admin", "admin");
     return client.HasDatabase("heatmap");
 }
示例#6
0
			public CouchDbIntent(string name){
				_intent = new RuntimeStorage();
				_intent.filename = name;
				_intent.data = new Dictionary<string, JToken>();

				CouchClient client = new CouchClient();

				if(!client.HasDatabase(DATABASE))
					client.CreateDatabase(DATABASE);

				CouchDatabase database = client.GetDatabase(DATABASE);

				CouchDbIntentData data = null;
				try{
					Document d = database.GetDocument(name);
					data = JsonConvert.DeserializeObject<CouchDbIntentData>(d.ToString());
				}catch{

				}

				if(data == null)
				{
					data = new CouchDbIntentData();

					data.data = new Dictionary<string, JToken>();
					Document<CouchDbIntentData> tosave = new Document<CouchDbIntentData>(data);
					tosave.Id = name;
					database.CreateDocument( tosave );
				}

                if (data.data != null)
                {
                    foreach (var entry in data.data)
                    {
                        _intent.data.Add(entry.Key, entry.Value);
                    }
                }
			}
示例#7
0
 public void Setup()
 {
     var connection = new CouchConnection()
     {
         Username = username,
         Password = password,
         AuthenticationType = AuthenticationType.Cookie,
         DbType = DbType.CouchDb,
         DatabaseName = baseDatabase
     };
     connection.ConfigureBaseUri(host, port, false);
     client = new CouchClient(connection);
     if (!client.HasDatabase(baseDatabase))
     {
         client.CreateDatabase(baseDatabase);
     }
     if (!client.HasDatabase(replicateDatabase))
     {
         client.CreateDatabase(replicateDatabase);
     }
 }
示例#8
0
        private static CouchDatabase GetDatabase(string library)
        {
            CouchClient client = new CouchClient();
            CouchDatabase db = null;
            if (!client.HasDatabase(library))
            {
                client.CreateDatabase(library);
                JObject annotationViewsJson = JObject.Parse(File.ReadAllText(_annotationViewsFile));
                JObject annotationDesignDoc = new JObject();
                annotationDesignDoc["language"] = "javascript";
                annotationDesignDoc["views"] = annotationViewsJson;

                JObject screenshotViewsJson = JObject.Parse(File.ReadAllText(_screenshotViewsFile));
                JObject screenshotDesignDoc = new JObject();
                screenshotDesignDoc["language"] = "javascript";
                screenshotDesignDoc["views"] = screenshotViewsJson;

                
                db = client.GetDatabase(library);

                Document aView = new Document(annotationDesignDoc);
                aView.Id = "_design/annotations";
                

                Document sView = new Document(screenshotDesignDoc);
                sView.Id = "_design/screenshots";


                db.CreateDocument(aView);
                db.CreateDocument(sView);
            }

            db = client.GetDatabase(library);

            return db;
        }