📜  mongodb 中的文档自动过期 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:22.693000             🧑  作者: Mango

代码示例1
> db.notifications.createIndex({"createdAt":1,"text":1}, {expireAfterSeconds:86400})
    {
        "operationTime" : Timestamp(1599925286, 1),
        "ok" : 0,
        "errmsg" : "TTL indexes are single-field indexes, compound indexes do not support TTL. Index spec: { key: { createdAt: 1.0, text: 1.0 }, name: \"createdAt_1_text_1\", expireAfterSeconds: 86400.0 }",
        "code" : 67,
        "codeName" : "CannotCreateIndex",
        "$clusterTime" : {
            "clusterTime" : Timestamp(1599925286, 1),
            "signature" : {
                "hash" : BinData(0,"mCmm0gKiYCSNIpYEggT3LloGKdw="),
                "keyId" : NumberLong("6848960729458933762")
            }
        }
    }