Is it possible to create view from PHP script? How?
Yes it is possible. We have not documented the feature (but it will come soon see http://www.couchbase.com/issues/browse/PCBC-172 )
The code to achieve that is the following :
... $name = "dev_myView"; $map = '{"views":{"myview":{"map":"function (doc, meta) { emit(meta.id, NULL); }"}}}'; $ret = $cb->setDesignDoc($name, $map); ...
If you need more information you can look at the test cases: - https://github.com/couchbase/php-ext-couchbase/blob/master/tests/DesignD... - https://github.com/couchbase/php-ext-couchbase/blob/master/tests/ViewBas...
regards
Tug @tgrall
Yes it is possible. We have not documented the feature (but it will come soon see http://www.couchbase.com/issues/browse/PCBC-172 )
The code to achieve that is the following :
... $name = "dev_myView"; $map = '{"views":{"myview":{"map":"function (doc, meta) { emit(meta.id, NULL); }"}}}'; $ret = $cb->setDesignDoc($name, $map); ...If you need more information you can look at the test cases:
- https://github.com/couchbase/php-ext-couchbase/blob/master/tests/DesignD...
- https://github.com/couchbase/php-ext-couchbase/blob/master/tests/ViewBas...
regards
Tug
@tgrall