Previous Page Next Page

Now it is time to set up the design of the database.

Create NSF

Add a request as previously.

  1. Rename it “Create Contacts NSF”
  2. Change “GET” to “POST”.
  3. Set the request URL to “{{SETUPHOST}}/design/nsf?dataSource={{CONTACTS}}”.
  4. On the Headers tab, add a header “Content-Type” set to “application/json”.
  5. On the Body tab, select raw and enter:

     {
         "nsfPath" : "collabsphere.nsf",
         "title" : "Collabsphere Demo"
     }
    
  6. Send the request.

You should receive a response that includes the information about the newly-created NSF. This request has also created a Domino REST API Schema for the new database.

Create Scope

Before we can create design elements, we also need to create a Domino REST API Scope for the database.

Schemas and Scopes

Exposing a database with Domino REST API comprises two parts - the Domino REST API Schema and the Domino REST API Scope.

The schema defines what can be exposed and requires an understanding of the database design. It will usually be set up by a developer and is stored as part of the database.

The scope defines whether it is exposed and is stored centrally on the server. Depending on the division of responsibilities for the Domino server, this may be done by an administrator or a developer.

Creating the NSF automatically creates a basic schema, although with nothing exposed.

Before we can continue creating the design programmatically, we need to expose a scope. This could be done via the Domino REST API’s Admin UI. The Domino ToDo Database tutorial is a tutorial that takes that approach. In this tutorial, the scope and schema will be managed via REST API calls.

  1. Add a request as previously.
  2. Rename it “Create Scope”
  3. Change “GET” to “POST”.
  4. Set the request URL to “{{SETUPHOST}}/admin/scope?createSchema=true”.
  5. On the Headers tab, add a header “Content-Type” set to “application/json”.
  6. On the Body tab, select raw and enter:

     {
         "apiName": "{{CONTACTS}}",
         "schemaName": "{{CONTACTS}}",
         "nsfPath": "collabsphere.nsf",
         "isActive": true
     }
    
  7. Send the request.

Create Form

Add another request.

  1. Rename it “Create Form”
  2. Change “GET” to “PUT”.
  3. Set the request URL to “{{SETUPHOST}}/design/forms/Contact?dataSource={{CONTACTS}}”.
  4. On the Headers tab, add a header “Content-Type” set to “application/json”.
  5. On the Body tab, select raw and enter:

     {
         "name" : "Contact",
         "alias": "",
         "fields" : [
             {
                 "name" : "first_name",
                 "type": "text",
                 "allowmultivalues" : false
             },
             {
                 "name" : "last_name",
                 "type": "text",
                 "allowmultivalues" : false
             },
             {
                 "name" : "email",
                 "type": "text",
                 "allowmultivalues" : false
             },
             {
                 "name" : "gender",
                 "type": "text",
                 "allowmultivalues" : false
             },
             {
                 "name" : "city",
                 "type": "text",
                 "allowmultivalues" : false
             },
             {
                 "name" : "state",
                 "type": "text",
                 "allowmultivalues" : false
             }
         ]
     }
    

    This creates the Form with six text fields, all single value - first_name, last_name, email, gender, city, state.

  6. Send the request.

You should receive a 200 JSON response echoing the schema configuration.

Create By Name View

Add another request.

  1. Rename it to “Create View By Name”
  2. Change “GET” to “PUT”
  3. Set the request URL to “{{SETUPHOST}}/design/views/byName?dataSource={{CONTACTS}}”.
  4. On the Headers tab, add a header “Content-Type” set to “application/json”.
  5. On the Body tab, select raw and enter:

     {
         "name" : "byName",
         "selectionFormula" : "Form = \"Contact\"",
         "columns" : [
             {
                 "name": "firstName",
     			"title": "First Name",
         		"separatemultiplevalues": false,
             	"sort": "ascending",
                 "formula": "firstName"
     		},
             {
         		"name": "last_name",
     			"title": "Last Name",
                 "separatemultiplevalues": false,
             	"sort": "ascending",
         		"formula": "last_name"
     		},
             {
             	"name": "email",
         		"title": "Email",
     			"separatemultiplevalues": false,
                 "sort": "ascending",
             	"formula": "email"
         	},
             {
             	"name": "city",
         		"title": "City",
     			"separatemultiplevalues": false,
                 "sort": "ascending",
             	"formula": "city"
         	},
             {
                 "name": "state",
             	"title": "State",
         		"separatemultiplevalues": false,
     			"sort": "ascending",
                 "formula": "state"
             }
         ]
     }
    
  6. Send the request.

You should receive a JSON response {"success": true}.

Create By State View

Add another request.

  1. Rename it to “Create View By State”
  2. Change “GET” to “PUT”
  3. Set the request URL to “{{SETUPHOST}}/design/views/byState?dataSource={{CONTACTS}}”.
  4. On the Headers tab, add a header “Content-Type” set to “application/json”.
  5. On the Body tab, select raw and enter: {% raw %}
     {
         "name" : "byState",
         "selectionFormula" : "Form = \"Contact\"",
         "columns" : [
             {
                 "name": "state",
     			"title": "State",
         		"separatemultiplevalues": false,
             	"sort": "ascending",
                 "formula": "state"
     		},
         	{
             	"name": "firstName",
                 "title": "First Name",
     			"separatemultiplevalues": false,
         		"sort": "ascending",
             	"formula": "firstName"
             },
             {
         		"name": "last_name",
             	"title": "Last Name",
                 "separatemultiplevalues": false,
     			"sort": "ascending",
         		"formula": "last_name"
             },
             {
         		"name": "email",
             	"title": "Email",
                 "separatemultiplevalues": false,
     			"sort": "ascending",
         		"formula": "email"
             },
             {
         		"name": "city",
             	"title": "City",
                 "separatemultiplevalues": false,
     			"sort": "ascending",
         		"formula": "city"
             }
         ]
     }
    
  6. Send the request.

You should receive a JSON response {"success": true}.

Now we are ready to update the schema. This will be done via Postman.

Previous Page Next Page