Hi @all!
Couchbase Lite is driving me nuts at the moment :(
I try to achieve a simple filtering on the stored person documents which
mets the following criterias:
- I got multiple *optional* filter criterias such as "Name", "Gender" or
"Group"
- The sort order should be [firstName,lastName]
The Person Model looks like the following (as for now only testing with
"gender"):
@objc(Person)
class Person: CBLModel{
@NSManaged var firstName: NSString?
@NSManaged var lastName: NSString?
@NSManaged var gender: Label?
@NSManaged var groups: NSArray?
class func groupsItemClass() -> AnyClass{
return Group.self
}
}
And my view map function looks like:
{ (doc, emit) -> Void in
if (doc["type"] as? String) == "Person" {
var key: [AnyObject] = []
var params = [String:AnyObject]()
if let gender = doc["gender"] as? String{
params["gender"] = gender
}
key.append(params)
if let firstName = doc["firstName"] as? String{
key.append(firstName)
} else {
key.append("")
}
if let lastName = doc["lastName"] as? String{
key.append(lastName)
} else {
key.append("")
}
emit(key,nil)
}
}
Basically my idea was to use a dictionary as the first view param, since in
the docs I read somewhere it's order is undefined.
And afterwards use "firstName" and "lastName" for the sort in the view key.
But unfortunately it doesn't work :(
How to solve this issue, so I'm able to call a function with optional
filter params?
The goal should look something like this:
func filter(params: [String:AnyObject]? = nil) -> CBLQueryEnumerator
--
You received this message because you are subscribed to the Google Groups
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/mobile-couchbase/7c440c27-3171-4ace-a20d-aaa56555b4c4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.