Several years back, when designing the Perl client (before I was working for Couchbase), I wanted an efficient way to handle processing view results as they arrived from the network without having to wait for all the rows to arrive so they could be parsed as a proper JSON array. To solve this problem, I create the jsonsl library to incrementally parse the JSON rows – allowing users of this library to receive data as it arrives despite not yet having a complete JSON object.
Support for this feature was implemented to a certain degree in both the Python and Perl clients. Now it's finally made its way into the C library. This adds the benefit of the enhanced testing infrastructure found in the C client, but also an improved API – which for C users, should be much simpler than the raw HTTP API.
Using the views API
Here's an example of how to use it:
The new view functionality also includes the ability for the library to fetch documents for the results. Simply set the LCB_CMDVIEWQUERY_F_INCLUDE_DOCS flag in the cmd.cmdflags field.
Using the N1QL API
N1QL is an experimental feature to be added in future versions of Couchbase. It is available as a developer preview (http://docs.couchbase.com/developer/n1ql-dp3/n1ql-intro.html). Version 2.4.7 of the client provides some new APIs to interface with N1QL.
Using the N1QL API is very similar to the views API. Like views, it is row-based. Unlike views however, the passing of N1QL query parameters is more abstracted (because of its complexity) and involves creating a special “parameters” object.
Simply follow the normal upgrade/install instructions