Can individual fields expire in MongoDB?

I would like to know if it is possible to finish individual fields in a document, and not the entire document.

After reading the documentation on TTL indexes and expiring data , it is possible that field-based documents can be completed, however I would like to confirm.

The background for this question is that I have a Statistics collection with fields for monthly, weekly, daily, and hourly statistics in each document. I could break it down into 4 separate collections so that the documents in each collection could use different TTLs, however I believe that it would also mean that I would need to properly split my bulk updates into one bulk update for each collection. I would like, if possible, to use the effectiveness of one separate operation.

+4
source share
2 answers

This is not yet possible.

, db. , : , 1 slave mongo ( , ). .

+1

: , downvotes , , , , . , , - , . :


, MongoDB 2.2, . MongoDB.

:

, , expireAfterSeconds 0.

db.log_events.ensureIndex(
    { "expireAt": 1 },
    { expireAfterSeconds: 0 }
)

, expireAt, , :

db.log_events.insert({
    "expireAt": new Date('July 22, 2013 14:00:00'),
    "logEvent": 2,
    "logMessage": "Success!"
})

.

0

All Articles