- Previous
- Next
Step 2 - Return field values
Our application works, but it doesn’t return much data we can use. Let’s change that.
-
Save the file as
exercise1b.js
.This will help in case you need to go back and start over. :-)
-
Add fields you want returned.
Here is the current call:
const docs = await db.bulkReadDocuments({ query: query });
You can change the call to add fields you want returned. The domino-db API currently has no way to give you a list of what fields are available, so you’ll need to use the Notes client to get those. You don’t have to open the Notes client for this lab (although you are welcome to do so; the password is
passw0rd
). Here are some of the fields in the document:The API will return any fields it finds in an array called
itemNames
. Edit the call so it includes theFirstName
andLastName
fields, as shown below:const docs = await db.bulkReadDocuments({ query: query, itemNames: [ 'FirstName', 'lastname' ] });
-
Save the file and run it from the command line with
node exercise1b.js
. Your results should look something like this:Note that data from the
LastName
field is returned, even though we put the name all in lower case. The API is not case sensitive when it comes to the names of the fields, soLastName
andlastname
will both work, and the JSON which is returned will use the case you specify.
- Previous
- Next