- Previous
- Next
Step 1 - Your first app
The domino-db package is installed and you are ready to write your first node.js application.
-
From the Desktop, double click on the
Think_6051
directory. -
From there, open the
exercises
directory, where you’ll see the file calledexercise1.js
. Right click on that file and choose Open with -> Atom.The file should open in the Atom editor. Note the first few lines of the code:
These lines do three things:
- Require (import) the domino-db package.
- Define the server by host name and port.
- Identify the database to be used by directory and file name.
-
Starting on line 18 is the section which uses the
bulkReadDocuments
API call, passing a query. That query is a Domino Query Language string which needs to be created in the application. You can see that string in line 14, commented out. Uncomment that line and save the file, as shown below. -
This query will return all documents which have the string
Contact
in the field namedForm
. Let’s test the application from the command prompt. You should already have a command prompt open (if not, open one by clicking on its icon in the system tray and change to theDesktop\Think_6051\exercises
directory). -
Run the program by typing
node exercise1.js
and hitting Enter. You should see results scroll across the screen, similar to the screen shot below:
The documentRange
object contains useful information about the query: there are a total of 200 documents in the database matching the query (total: 200
), and the call has returned 100 documents (count: 100
), starting with the first document (start: 0
).
Also notice that we have some information about each document. For each document, a domino-db request will return three values:
@unid
- the unique ID of the document@created
- the date the document was created@modified
- the date the document was last modified
This is somewhat useful to us, but it might be more useful to also return the values in the various fields of the document. To do this, we modify the values we send in the bulkReadDocuments
call. We’ll do that in the next exercise.
- Previous
- Next