Extending the N1QL query language by adding your own functions written in JavaScript
Introduction
N1QL includes a large number of operations and generic functions that cover every aspect of data manipulation. In addition to the built-in functions, Couchbase also allows you to create your own extensions to the language.
Using User-Defined Functions, you can:
-
Create reuseable, domain-specific functions for use in your applications.
-
Execute complex logic that may be difficult to do in N1QL.
-
Migrate from RDBMS stored procedures.
User-Defined Functions with JavaScript
JavaScript that is supported in Couchbase shares the same constructs of the ECMAScript, though there are a number of restrictions and also extensions with the Couchbase JavaScript implementation. (These are covered in JavaScript Functions with Couchbase)