public GetDatabase ( string databaseName ) : CouchDatabase | ||
databaseName | string | Name of database to fetch |
Résultat | CouchDatabase |
public ActionResult New(string projectName) { var client = new CouchClient("dannylane.iriscouch.com", 6984, "dannylane", "adminpass", true, AuthenticationType.Cookie); var userresult = client.CreateUser(projectName, projectName); //var newUid = userresult.Value<string>("id"); var u = client.GetUser(projectName); u["roles"] = new JArray(projectName + "reader_"); var udb = client.GetDatabase("_users"); udb.SaveDocument(u); var res = client.CreateDatabase(projectName); var db = client.GetDatabase(projectName); var security = db.getSecurityConfiguration(); security.readers.roles.Add(projectName + "reader_"); db.UpdateSecurityDocument(security); var readerClient = new CouchClient("localhost", 5984, projectName, projectName, false, AuthenticationType.Cookie); // var result = CouchBase.GetSession("localhost:5984", projectName, projectName); Response.Cookies.Add(new HttpCookie("auth", readerClient.GetSession().Value)); return View(); }
public LoveSeat.ViewResult List() { var client = new CouchClient("dannylane.iriscouch.com", 6984, "dannylane", "adminpass", true, AuthenticationType.Cookie); var udb = client.GetDatabase("testing"); return udb.GetAllDocuments(); // return new JsonResult {Data = db, JsonRequestBehavior = JsonRequestBehavior.AllowGet}; }
public ActionResult Index(string errorMessage) { var client = new CouchClient("dannylane.iriscouch.com", 6984, "dannylane", "adminpass", true, AuthenticationType.Cookie); var udb = client.GetDatabase("testing"); JObject jObject = new JObject(); jObject.Add("DateTime", DateTime.UtcNow); jObject.Add("UserHostAddress", Request.UserHostAddress); jObject.Add("UserHostName", Request.UserHostName); // jObject.Add("UserLanguages", Request.UserLanguages.ToString()); foreach (var param in Request.QueryString.AllKeys) { jObject.Add(param, Request.QueryString[param]); } foreach (var param in Request.Headers.AllKeys) { jObject.Add(param, Request.Headers[param]); } var info = new LoveSeat.Document(jObject); udb.SaveDocument(info); return File("favicon.ico","image"); }
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); } }
static void Main(string[] args) { var client = new CouchClient("alwalker.cloudant.com", 443, "alwalker", "PASSWORD", true, AuthenticationType.Basic); var db = client.GetDatabase("cloudant-tutorial"); Document untyped = db.GetDocument("966f8b38cba7a782899997c3487345ea"); Thingy typed = db.GetDocument<Thingy>("966f8b38cba7a782899997c3487345ea"); Console.WriteLine("balls"); Console.ReadLine(); }
public void WriteData(Vector2 position, int level, int diedInPhase, int totalPhases, bool died = false) { //Create the object. JsonObject obj = new JsonObject(); obj.X = (int)position.X; obj.Y = (int)position.Y; obj.Level = level; obj.DiedInPhase = diedInPhase; obj.TotalPhases = totalPhases; obj.Died = died; //Use string json = JsonConvert.SerializeObject(object); to get the object in json format. string json = JsonConvert.SerializeObject(obj); //Connect with the database. var client = new CouchClient("admin", "admin"); var db = client.GetDatabase("heatmap"); //Now add the object to the database. db.CreateDocument(json); }
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); }
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); } } }
public SummonerProducer(CouchClient db) { _summoners = db.GetDatabase(DatabaseName); _summoners.SetDefaultDesignDoc(IndexName); }
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; }