node package manager



A Yeoman generator for MLJS


To be able to generate an MLJS application using the generator you will need two things installed. The first is Yeoman. The second is the generator. Go ahead and take a moment to install them.

I'll wait.

$ npm install -g yo
$ npm install -g generator-mljs

There, that's better, isn't it? You'll also need MarkLogic installed. Fortunately, this is not painful.

Download MarkLogic from the faithful and trustworthy MarkLogic servers. Follow the simple instructions to get MarkLogic installed.

Your first App

To get started you'll need a content database and a REST database. Depending on your setup, an administrator may have already created one for you or you have admin rights and can create one yourself. Fortunately, if you do need to create one, the generator will create a simple setup to get you started.

Creating your own

You can skip this if there's already a server and db. When you type:

$ yo mljs

You are prompted with a series of questions. The first asks you to select your setup options. Choose "Create a content db and a rest service" from the menu.

You have a server and db

When you type

$ yo mljs

You will select "Nothing to do - REST service and content db exist."


Option Meaning
hostname Your MarkLogic server hostname or IP address
admin username Required if you need to create a new REST service, optional otherwise
admin password Required if you need to create a new REST service, otherwise optional
service name The name you want to give your service so you can identify it.
service port The port the REST service should use
content db name The name of the content db to use or create.


    |       |
    |--(o)--|   .--------------------------.
   `---------´  |    Welcome to Yeoman,    |
    ( _´U`_ )   |   ladies and gentlemen!  |
    /___A___\   '__________________________'
     |  ~  |
 ´   `  |° ´ Y `
You're using the fantastic Mljs generator.
[?] Select your setup options: Create a content db and a rest service
[?] What is your MarkLogic Server hostname? localhost
[?] What is your admin username? admin
[?] What is your admin password? x8kia30
[?] What's Rest Service Name? myotherservice
[?] What's the REST Service Port? 9997
[?] What's the content database name? (MyDb)

Where to Go from Here

Assuming everything went well, what you have at this point is a functioning Node/Express application with support for MLJS. What you need to determine is how you will use MLJS.

You can use MLJS from your Node (server side) code. In this case you will make calls to the rest service directly from your Node app.

You can also use MLJS from the browser. In this case your Node application is serving content and the queries execute directly against the MarkLogic server from your browser.

This generator currently supports both modes by both loading the NPM module for MLJS and the bower components for MLJS browser widgets.

MLJS Documentation