my document
let properties: [String : Any] = [
"project_id":Task.project_id!,
"title": title,
"parent_id": parent_id,
"weight": "1",
"created_at": DateTime.DateTime(),
"updated_at": DateTime.DateTime(),
"type": "group",
"tag_id":tagId,
"owner": Session.username!,
]
I want to find data according to condition.
I mean, I want to get which document where parent_id is not nil("") or null. I am using this query
func setupViewAndQuery() {
let listsView = database.viewNamed("list/GroupDropDown")
if listsView.mapBlock == nil {
listsView.setMapBlock({ (doc, emit) in
if let type: String = doc["type"] as? String, let name = doc["title"], let parent_id = doc["parent_id"] as? String, let created = doc["created_at"], let updated = doc["updated_at"], let Id = doc["_id"]
, type == "group", parent_id != "" {
emit([name,parent_id,created,updated,Id], nil)
}
}, version: "1.0")
}
listsLiveQuery = listsView.createQuery().asLive()
listsLiveQuery.addObserver(self, forKeyPath: "rows", options: .new, context: nil)
listsLiveQuery.start()
}
but this function returns all data. how to do this task?
couchBase Mobile 1.4