meteor-astronomy icon indicating copy to clipboard operation
meteor-astronomy copied to clipboard

Adding TTL to select fields

Open martineboh opened this issue 7 years ago • 2 comments

Adding TTL via fields in a Class, so Mongo knows when to auto delete them after sometime?! Just a suggestion...

martineboh avatar Mar 11 '17 10:03 martineboh

You should be able to create such an index. Try this:

import { Class } from 'meteor/jagi:astronomy';

const Item = Class.create({
  name: 'Item',
  collection: Items
  fields: {
    lastModifiedDate: Date
  },
  indexes: {
    lastModifiedDate: { // Index name.
      fields: { // List of fields.
        lastModifiedDate: 1
      },
      options: { // Mongo index options.
        expireAfterSeconds: 3600
      }
    }
  }
});

lukejagodzinski avatar Mar 12 '17 18:03 lukejagodzinski

Thanks! You rock!

On Mar 12, 2017 7:42 PM, "jagi" [email protected] wrote:

You should be able to create such an index. Try this:

import { Class } from 'meteor/jagi:astronomy'; const Item = Class.create({ name: 'Item', collection: Items fields: { lastModifiedDate: Date }, indexes: { lastModifiedDate: { // Index name. fields: { // List of fields. lastModifiedDate: 1 }, options: { // Mongo index options. expireAfterSeconds: 3600 } } } });

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jagi/meteor-astronomy/issues/598#issuecomment-285964816, or mute the thread https://github.com/notifications/unsubscribe-auth/ADoalJxKyA1yy_q4z9DOMdOqvAHYwYYOks5rlDydgaJpZM4MaKof .

martineboh avatar Mar 14 '17 15:03 martineboh