本文整理汇总了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;
}
示例2: Conversation
static Conversation()
{
database = Manager.SharedInstance.GetDatabase ("conversations");
defaultView = database.GetView ("conversation-messages");
defaultView.SetMap ((document, emit) => {
//
}, "1");
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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 ();
}
示例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();
}
示例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;
}
示例12: CreateView
public static View CreateView(Database db)
{
View view = db.GetView("aview");
view.SetMapReduce(new _Mapper_172(), null, "1");
return view;
}
示例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();
}
}
示例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();
}