当前位置: 首页>>代码示例>>C#>>正文


C# Database.GetView方法代码示例

本文整理汇总了C#中Couchbase.Lite.Database.GetView方法的典型用法代码示例。如果您正苦于以下问题:C# Database.GetView方法的具体用法?C# Database.GetView怎么用?C# Database.GetView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Couchbase.Lite.Database的用法示例。


在下文中一共展示了Database.GetView方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetQuery

 public static Query GetQuery(Database database, string listDocId)
 {
     View view = database.GetView(ViewName);
     if (view.Map == null)
     {
         view.Map += (IDictionary<string, object> document, EmitDelegate emitter)=> 
         {
             if (Task.DocType.Equals(document.Get("type")))
             {
                 var keys = new AList<object>();
                 keys.AddItem(document.Get("list_id"));
                 keys.AddItem(document.Get("created_at"));
                 emitter(keys, document);
             }
         };
     }
     Query query = view.CreateQuery();
     query.Descending = true;
     IList<object> startKeys = new AList<object>();
     startKeys.AddItem(listDocId);
     startKeys.AddItem(new Dictionary<string, object>());
     IList<object> endKeys = new AList<object>();
     endKeys.AddItem(listDocId);
     query.StartKey = startKeys;
     query.EndKey = endKeys;
     return query;
 }
开发者ID:transformersprimeabcxyz,项目名称:_TO-DO-couchbase-lite-net-couchbase,代码行数:27,代码来源:Task.cs

示例2: Conversation

 static Conversation()
 {
     database = Manager.SharedInstance.GetDatabase ("conversations");
     defaultView = database.GetView ("conversation-messages");
     defaultView.SetMap ((document, emit) => {
         //
     }, "1");
 }
开发者ID:CAMongrel,项目名称:OpenFlow,代码行数:8,代码来源:Conversation.cs

示例3: GetQuery

 public static Query GetQuery(Database database, string ignoreUserId)
 {
     View view = database.GetView(ViewName);
     if (view.GetMap() == null)
     {
         Mapper map = new _Mapper_30(ignoreUserId);
         view.SetMap(map, null);
     }
     Query query = view.CreateQuery();
     return query;
 }
开发者ID:jonlipsky,项目名称:couchbase-lite-net,代码行数:11,代码来源:Profile.cs

示例4: GetQueryById

 public static Query GetQueryById(Database database, string userId)
 {
     View view = database.GetView(ByIdViewName);
     if (view.GetMap() == null)
     {
         Mapper map = new _Mapper_52();
         view.SetMap(map, null);
     }
     Query query = view.CreateQuery();
     IList<object> keys = new AList<object>();
     keys.AddItem(userId);
     query.SetKeys(keys);
     return query;
 }
开发者ID:jonlipsky,项目名称:couchbase-lite-net,代码行数:14,代码来源:Profile.cs

示例5: GetQuery

        public static Query GetQuery(Database database)
        {
            var view = database.GetView(ViewName);
            if (view.Map == null)
            {
                view.SetMap((document, emitter) => 
                   {
                    object deleted;
                    document.TryGetValue(DeletedKey, out deleted);

                    if(deleted == null)
                        emitter (document["text"], document["check"]);
                    }, "2");
            }
            var query = view.CreateQuery();
            return query;
        }
开发者ID:jonfunkhouser,项目名称:couchbase-lite-net,代码行数:17,代码来源:List.cs

示例6: GetQuery

 public static Query GetQuery(Database database)
 {
     View view = database.GetView(ViewName);
     if (view.Map == null)
     {
         view.Map += (IDictionary<string, object> document, EmitDelegate emitter) =>
         {
             string type = (string)document.Get("type");
             if (List.DocType.Equals(type))
             {
                 emitter(document.Get("title"), document);
             }
         };
     }
     Query query = view.CreateQuery();
     return query;
 }
开发者ID:jonlipsky,项目名称:couchbase-lite-net,代码行数:17,代码来源:List.cs

示例7: GetQuery

        public static Query GetQuery(Database database)
        {
            var view = database.GetView(ViewName);
            if (view.Map == null)
            {
                view.SetMap((document, emitter) => 
                    {
                        object type;
                        document.TryGetValue("type", out type);

                        if (List.DocType.Equals ((string)type)) {
                            emitter (document["text"], document);
                        }
                    }, "1");
            }
            var query = view.CreateQuery();
            return query;
        }
开发者ID:FireflyLogic,项目名称:couchbase-lite-net,代码行数:18,代码来源:List.cs

示例8: ContactDatabase

        static ContactDatabase()
        {
            database = Manager.SharedInstance.GetDatabase ("contacts");
            emailLookup = new Dictionary<string, string> ();

            lookupView = database.GetView ("addresses");
            lookupView.SetMap ((document, emit) => {
                var val = document["contact.address.address"];
                emit(document["_id"], val);
            }, "1");

            Query lookupQuery = lookupView.CreateQuery ();

            BuildLookup(lookupQuery.Run ());

            lookupViewLiveQuery = lookupQuery.ToLiveQuery();
            lookupViewLiveQuery.Changed += (object sender, QueryChangeEventArgs e) => { BuildLookup(e.Rows); };
            lookupViewLiveQuery.Start ();
        }
开发者ID:CAMongrel,项目名称:OpenFlow,代码行数:19,代码来源:ContactDatabase.cs

示例9: InitializeCouchbase

        private void InitializeCouchbase()
        {
            _db = Manager.SharedInstance.GetDatabase("wpf-lite");
            
            var view = _db.GetView("todos");

            if (view.Map == null)
            {
                view.SetMap((props, emit) =>
                {
                    Console.WriteLine("Mapper mapping");
                    emit(DateTime.UtcNow.ToString(), props["text"]);
                }, "1");
            }

            _query = view.CreateQuery().ToLiveQuery();
            _query.Changed += QueryChanged;
            _query.Completed += QueryCompleted;
            _query.Start();
        }
开发者ID:transformersprimeabcxyz,项目名称:_TO-DO-couchbase-lite-net-couchbase,代码行数:20,代码来源:MainPage.xaml.cs

示例10: TaskManager

        public TaskManager ()
        {
            _db = Manager.SharedInstance.GetDatabase("kitchen-sync");
            View view = _db.GetView("viewItemsByDate");
            view.SetMap((doc, emit) => {
                if(doc.ContainsKey("created_at") && doc["created_at"] is DateTime) {
                    emit(doc["created_at"], null);
                }
            }, "1");

            _query = view.CreateQuery().ToLiveQuery();
            _query.Descending = true;
            _query.Changed += (sender, e) => {
                if(TasksUpdated != null) {
                    var tasks = from row in e.Rows
                        select Task.FromDictionary(row.Document.Properties);
                    TasksUpdated(this, tasks.ToList());
                }
            };

            _query.Start();
        }
开发者ID:richardkeller411,项目名称:dev-days-labs,代码行数:22,代码来源:TaskManager.cs

示例11: CreateView

 public static View CreateView(Database db)
 {
     var view = db.GetView("aview");
     view.SetMapReduce((IDictionary<string, object> document, EmitDelegate emitter)=>
         {
             Assert.IsNotNull(document["_id"]);
             Assert.IsNotNull(document["_rev"]);
             if (document["key"] != null)
             {
                 emitter(document["key"], null);
             }
         }, null, "1");
     return view;
 }
开发者ID:SunilDhaker,项目名称:couchbase-lite-net,代码行数:14,代码来源:ViewsTest.cs

示例12: CreateView

		public static View CreateView(Database db)
		{
			View view = db.GetView("aview");
			view.SetMapReduce(new _Mapper_172(), null, "1");
			return view;
		}
开发者ID:Redth,项目名称:couchbase-lite-net,代码行数:6,代码来源:ViewsTest.cs

示例13: Start

    void Start()
    {
        DontDestroyOnLoad(this);
        if (FindObjectsOfType(GetType()).Length > 1)
        {
            Destroy(gameObject);
            return;
        }
        manager = Manager.SharedInstance;
        db = manager.GetDatabase(Constants.DB_NAME);
        db.Changed += (sender, e) => {
            var changes = e.Changes.ToList();
            foreach (DocumentChange change in changes) {
                print("Document " + change.DocumentId + " changed");
            }
        };

        // initialize views
        // account username-password
        View viewAccount = db.GetView(Constants.DB_TYPE_ACCOUNT);
        viewAccount.SetMap ((doc, emit) => {
            if(doc[Constants.DB_KEYWORD_TYPE].ToString () == Constants.DB_TYPE_ACCOUNT)
                emit(doc[Constants.DB_KEYWORD_USERNAME], doc[Constants.DB_KEYWORD_PASSWORD]);
        }, "1");

        // initialize database, use Unity inspector to change value in GameManager
        if (GameManager.Instance.initializeDatabase) {
            InitializeDatabase();
        }
    }
开发者ID:katongoukakyuu,项目名称:RSO,代码行数:30,代码来源:DatabaseManager.cs

示例14: InitializeCouchbase

        private void InitializeCouchbase()
        {
            _db = Manager.SharedInstance.GetDatabase("wpf-lite");
            _viewModel = new SimpleViewModel(new SimpleModel(Manager.SharedInstance, "wpf-lite"));
            if (_viewModel.SyncURL != null)
            {
                UpdateReplications(_viewModel.SyncURL);
            }

            _viewModel.PropertyChanged += (sender, args) =>
            {
                Console.WriteLine("Replication URL changed to {0}", _viewModel.SyncURL);
                UpdateReplications(_viewModel.SyncURL);
            };

            var view = _db.GetView("todos");

            if (view.Map == null)
            {
                view.SetMap((props, emit) =>
                {
                    object date;
                    if (!props.TryGetValue(CREATION_DATE_PROPERTY_NAME, out date)) {
                        return;
                    }

                    object deleted;
                    if (props.TryGetValue("_deleted", out deleted)) {
                        return;
                    }

                    emit(date, props["text"]);
                }, "1");
            }

            _query = view.CreateQuery().ToLiveQuery();
            _query.Changed += QueryChanged;
            _query.Start();
        }
开发者ID:jonfunkhouser,项目名称:couchbase-lite-net,代码行数:39,代码来源:MainPage.xaml.cs


注:本文中的Couchbase.Lite.Database.GetView方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。