我正在使用 AppDev Pack 为 domino 数据库创建 API。目前仅尝试 Domino AppDev Pack 中的示例代码。这是代码:
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");
});
通用 API 可以正常工作,但在这种情况下,我在设置代理时遇到错误。
TypeError: database.useAgent is not a function
有人可以建议我在这里缺少什么吗?请记住,这是文档中给出的示例代码。