Skip to content

Instantly share code, notes, and snippets.

@avsej
Created September 15, 2011 16:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avsej/1219776 to your computer and use it in GitHub Desktop.
Save avsej/1219776 to your computer and use it in GitHub Desktop.
Views API
view = libcouchbase_view_new(ddoc_name, view_name, options = NULL)
view->ddoc_name
view->view_name
view->url
view->options
view_result = libcouchbase_view_get_result(view);
view_result->rows
view_result->total_rows
view_result->offset
view_result = libcouchbase_view_get_result_async(view, callbacks);
callbacks->next_page_key_callback
callbacks->prev_page_key_callback
callbacks->head_callback
callbacks->row_callback
next_key_callback(view, next_key)
prev_key_callback(view, prev_key)
head_callback(view, head)
head->total_rows
head->offset
row_callback(view, row = NULL)
row->key
row->value
row->id
view_result_page = libcouchbase_view_get_result_page(view, page_key = NULL)
view_result_page->next_page_key
view_result_page->prev_page_key
view_result_page->rows
view_result_page->total_rows
view_result_page->offset
libcouchbase_view_result_get_result_page_async(view, callbacks, page_key = NULL)
callbacks->next_page_key_callback
callbacks->prev_page_key_callback
callbacks->head_callback
callbacks->row_callback
next_key_callback(view, next_key)
prev_key_callback(view, prev_key)
head_callback(view, head)
head->total_rows
head->offset
row_callback(view, row = NULL)
row->key
row->value
row->id
@avsej
Copy link
Author

avsej commented Sep 15, 2011

could you give some usecase for next_key_callback()? it should be called once the execution flow meets the document (and passes its key to callback)?

@janl
Copy link

janl commented Sep 15, 2011

I'm just breaking up all the potential return values for a result page (prev/next keys, head values and rows) into their own callbacks. They get called once per view result, so that afterwards you have the values to go forward or backward.

@avsej
Copy link
Author

avsej commented Sep 15, 2011

I see

@avsej
Copy link
Author

avsej commented Sep 15, 2011

the only thing I cannot understand is

next_key_callback(view, next_key)
prev_key_callback(view, prev_key)

When the driver will call them?

@janl
Copy link

janl commented Sep 15, 2011

basically as soon as the rows that hold that information are available to the library, but the only guarantee is that after the last row that has been sent, both callbacks already have been called. i.e. when the row_callback()'s row parameter is NULL at the end of the row iteration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment