Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

automatic expiry for a document in mongodb

    > 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")
            }
        }
    }
Source by dev.to #
 
PREVIOUS NEXT
Tagged: #automatic #expiry #document #mongodb
ADD COMMENT
Topic
Name
1+1 =