User-defined Functions with JavaScript

  • how-to
    Extending the N1QL query language by adding your own functions written in JavaScript


    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)

    Next Steps

    If you’re looking to creating your own JavaScript libraries then there are number of guides to get you started.

    If you wish to look into the constructs and available in the language itself, then you can have a look through the following pages: