Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

add spatial view and list functions #92

Closed
wants to merge 1 commit into from

4 participants

@mick

For those using the geocouch branch or using a couchbase build that support geospatial views, this added functions to call the spatial view and list API

@rojotek

It would be great to see this merged in.

@indexzero
Owner

We need test coverage here.

@sw360cab

does your code allow to create spatial 'view' as well ??

@indexzero
Owner

No tests

@indexzero indexzero closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 26 additions and 0 deletions.
  1. +26 −0 lib/cradle/database/views.js
View
26 lib/cradle/database/views.js
@@ -26,6 +26,20 @@ Database.prototype.view = function (path, options, callback) {
return this._getOrPostView(path, options, callback);
};
+// Query a spatial view, passing option to the query string.
+// Spatial views are available in geocouch (included in couchbase)
+Database.prototype.spatial = function(path, options, callback){
+ if (typeof options === 'function') {
+ callback = options;
+ options = {};
+ }
+
+ path = path.split('/');
+ path = ['_design', path[0], '_spatial', path[1]].map(querystring.escape).join('/');
+
+ return this._getOrPostView(path, options, callback);
+};
+
Database.prototype.temporaryView = function (doc, options, callback) {
if (!callback && typeof options === 'function') {
callback = options;
@@ -79,6 +93,18 @@ Database.prototype.list = function (path, options) {
);
};
+// Query a spatial list, passing any options to the query string.
+Database.prototype.spatialList = function (path, options) {
+ var callback = new(Args)(arguments).callback;
+ path = path.split('/');
+
+ this._getOrPostView(
+ ['_design', path[0], '_spatiallist', path[1], path[2]].map(querystring.escape).join('/'),
+ options,
+ callback
+ );
+};
+
//
// Helper function which parses options and makes either a `GET`
// or `POST` request to `path` depending on if `options.keys` or
Something went wrong with that request. Please try again.