Branching out: Let's tackle Node.js
Mon 3 Feb 2020, 11:16 AMTweet
by Ben Langhinrichs
Posts in this series:
- The tree you are busy hugging has new branches,
- Branching out: A few terms
- Branching out: REST, gRPC, and other gory details you can (mostly) ignore
- Branching out: No REST for the wicked - Part 1
- Branching out: No REST for the wicked - Part 2
- Branching out: Let's tackle Node.js
- Branching out: More CRUD with domino-db
- Branching out: Why the domino-db Document is not like NotesDocument
- Branching out: Models, msgs, and microservices
Let's try this! - I'm going to dive in rather than keep defining stuff. If you install the AppDev Pack (more on that installation in another post), you wind up with different pieces in different places. I want to use the latest version, so assume Domino 11 and AppDev Pack 1.0.3, but most of what I say applies to Domino 10 with AppDev Pack 1.0.2.
Proton is a Domino server addin. In a production environment that used domino-db on the client, it would also be loaded in the ServerTasks line, but let's load it manually for now. (Console image tweaked so it would fit horizontally.)
A couple of things to notice. One, this is set up for Anonymous access only. That means I am not using the IAM service yet. That will be a while different post (which I dread). Two, notice that third line says "Listening on 127.0.0.1:51860, INSECURE". That means the server addin is listening on a port, waiting for gRPC messages. The client/server interaction is is via messages sent over a gRPC protocol. Before you get all scared, realize that your regular Notes/Domino client/server interaction isvia messages sent over an NRPC protocol. In other words, this is the same sort of remote procedure call as you are used to, just not quite so hidden by the interface. You can do this.
So, let's try this out. We have to go to a command line where Node.js is installed, and simply run it.
That was unexciting, because it is a command line, and everything is unexciting. But if we open the node-demo.nsf database on the server and take a look, we find the two documents. Here is one, easily distinguished because we only set a couple of fields for Bernard Zelnick.
We could, of course, have added those other fields. There is also a flag we could have sent which would do a compute with form at the end of the update, useful both for computed fields and for executing input and validation formula. Perhaps an id is required, in which case the validation formula and the entire update would fail. So, there's lots more to explore, but I will leave you with a limitation from the documentation on that JSON payload which will be very important in a couple of subsequent posts.
If you wanted to include a photo of the person, or a profile with links, or whatever, you couldn't do it easily. Just something to bear in mind.
Note: Please ask if you'd like me to focus on any specific aspects. There's a ton of stuff, and I am open to taking on different parts that may be confusing or important or whatever/ Just ask.
Copyright © 2020 Genii Software Ltd.
What has been said:
1114.1. Dennis Jones (02/04/2020 11:37 AM)
Thanks for your series Ben. It helps break the ice with the features of Domino!