-
Notifications
You must be signed in to change notification settings - Fork 27
Open
Description
I have the following view :
let design = DesignDocument(_id: "_design/mydesign", views: [
"count_doc": [
"map": "function(doc) { if(doc.type == 'mydoc') { emit(doc._id, 1); } }",
"reduce": "_count"
]
])
in version 2.1.0 I was able to get the result with the following code:
database.queryByView("count_doc", ofDesign: "mydesign", usingParameters: []) { (doc, err) in
if let doc = doc, err == nil {
if let count = doc["rows"][0]["value"].int {
completion(count, nil)
} else {
completion(0, nil)
}
} else {
completion(nil, err)
}
}
Now in the current version:
database?.queryByView("count_doc", ofDesign: "mydesign", usingParameters: []) { (doc, err) in
if let doc = doc, err == nil {
if let count = doc.total_rows {
completion(count, nil)
} else {
completion(0, nil)
}
} else {
completion(nil, err)
}
}
I get the error
Failed to decode AllDatabaseDocuments from response
which is correct since the result is something like
{"rows":[ {"key":null,"value":26} ]}
Can you tell me how to retrieve the result from this view or a view that contains "_stats" function ?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels