I am using the AppDev Pack to create an API for a domino database. Currently trying only the sample code present in the Domino AppDev Pack. Here is the code:
app.get("/lastUpdated", (req, res, next) => {
//const operationName = req.params.operationName;
console.log("0");
const agentRunExample = (async () => {
console.log("1");
// Initialize the Server, Database and Agent objects.
const server = await useServer(serverConfig);
console.log("2");
const database = await server.useDatabase({ filePath: 'develop/node-demo.nsf' });
console.log("3");
const agent = await database.useAgent({ name: 'AppDevLastModified' });
console.log("4");
// Create the context document with data to pass to the agent.
const contextUnid = await database.createDocument({
document: {
param1: 'aa',
param2: 'bb',
},
});
console.log("5");
// * a context document that the agent can read/write
await agent.run({
//selection: { search: { query: "Form = 'VA'" } },
context: { unid: contextUnid },
});
console.log("6");
// sample agent updates the 'found_docs' item.
const result = await database.bulkReadDocumentsByUnid({
unids: [contextUnid],
itemNames: ['found_docs'],
});
console.log("7");
// Return the latest copy of the context document.
const [doc] = result.documents;
return doc;
})().catch(error => {
console.log(error);
});
console.log("end0");
res.json(agentRunExample);
console.log("end1");
});
The general APIs are working, but in this case, I am getting the error when setting the agent.
TypeError: database.useAgent is not a function
Can anybody suggest what I am missing here? Remember this is the sample code given in the documentation.