コード例 #1
0
        private void InitDb()
        {
            Connection connection = new Connection(new Uri(Config.HOST));

            connection.DeleteDatabase(Config.CLOTHES_DB_NAME);

            //if (!connection.ListDatabases().Any(db => db == Config.CLOTHES_DB_NAME))
            //{
            connection.CreateDatabase(Config.CLOTHES_DB_NAME);

            Session session = connection.CreateSession(Config.CLOTHES_DB_NAME);

            string allClothesScript =
                File.ReadAllText(HttpContext.Current.Server.MapPath("~/App_Data/all-clothes-map.js"));

            string colorsMap =
                File.ReadAllText(HttpContext.Current.Server.MapPath("~/App_Data/colors-map.js"));

            string colorsReduce =
                File.ReadAllText(HttpContext.Current.Server.MapPath("~/App_Data/colors-reduce.js"));

            DesignDocument designDocument = new DesignDocument();
            designDocument.Language = "javascript";
            designDocument.Views = new Dictionary<string, View>();

            designDocument.Views.Add("all-clothes", new View { Map = allClothesScript });
            designDocument.Views.Add("colors-breakdown", new View { Map = colorsMap, Reduce = colorsReduce });

            session.Save(designDocument, "_design/clothes-queries");
            //}
        }
コード例 #2
0
        private void CreateMapFunctions()
        {
            string mapFunction = File.ReadAllText("Scripts/owner-map.js");

            DesignDocument designDocument = new DesignDocument {Language = "javascript"};

            designDocument.Views = new Dictionary<string, View>();

            View view = new View {Map = mapFunction};

            designDocument.Views.Add("owner-map", view);

            _session.Save(designDocument, "_design/owner-queries");
        }
コード例 #3
0
 public void Session_preserves_design_document_when_reset()
 {
     var s = _cx.CreateSession(_sx.Database);
     var d = new DesignDocument {Language = "javascript"};
     s.Save(d, "_design/bang");
     s.Reset();
     var e = s.Load<DesignDocument>("_design/bang");
     Assert.That(e, Is.SameAs(d));
 }
コード例 #4
0
 public void Session_can_save_design_document()
 {
     var d = new DesignDocument { Language = "javascript" };
     _sx.Save(d, "_design/foo");
     Assert.True(_sx.ListDocuments().Any(x => x.Id == "_design/foo"));
 }
コード例 #5
0
        private void CreateMapFunctions()
        {
            string mapFunction = File.ReadAllText("Scripts/clothing-color-search-map.js");

            DesignDocument designDocument = new DesignDocument();

            designDocument.Language = "javascript";

            designDocument.Views = new Dictionary<string, View>();

            designDocument.Views.Add("color-search", new View() { Map = mapFunction });

            _session.Save(designDocument, "_design/clothes-queries-by-color");
        }