Query json property Couchbase.lite 2.0

query

#1

I am trying to do a .Where clause where the “doctype” = “Contact” and “doc.MiddleName” = “Nancy”
I am using Xamarin C#.

Here is the document
{
“CustomerCode”: “Bethany”,
“doc”: {
“FirstName”: “Ruth”,
“Id”: “Contact::78b86e91-5042-4b7a-8919-87189acb9df5”,
“LastName”: “Morris”,
“LastUpdated”: “636622580381941997”,
“Login”: null,
“MiddleName”: “Nancy”,
},
“doctype”: “Contact”
}

Here is the query:
using (var query = QueryBuilder.Select(SelectResult.All())
.From(DataSource.Database(App.CoreApp.Database))
.Where(Expression.Property(“doctype”).EqualTo(Expression.String(“Contact”))
.And(???)
))

Any help is appreciated!


#2

Expression.Property can handle nested values so in your case Expression.Property("doc.MiddleName") will specify the value you are after.


#3

Thanks! That was too obvious!