【发布时间】:2020-01-08 02:45:03
【问题描述】:
我在 node.js 中使用 cosmos db 进行会话存储。而cosmos db版本是3.6。
我执行以下代码。
const expressSession = require("express-session");
const MongoStore = require("connect-mongo")(expressSession);
const store = new MongoStore({
mongooseConnection: mongoose.connection,
ttl:24 * 60 * 60 * 1000,
})
结果显示以下消息。
(node:16068) UnhandledPromiseRejectionWarning: MongoError: The 'expireAfterSeconds' option is supported on '_ts' field only.
这个问题有什么解决办法?
【问题讨论】:
-
可能是因为你使用的是mongoose,它只支持MongoDB。 CosmosDB 是 Microsoft 产品,因此不受支持。
-
我使用 mongoose.mongoose 可以与 CosmosDB 一起使用。因为 CosmosDB 兼容 mongoApi。
标签: node.js azure-cosmosdb azure-cosmosdb-mongoapi