drudge / mongoose-timestamp

Adds createdAt and updatedAt date attributes that get auto-assigned to the most recent create/update timestamp
Other
308 stars 64 forks source link

How could I add es_indexed:true from Mongoosastic #32

Closed juanpujol closed 8 years ago

juanpujol commented 8 years ago

Awesome plugin!

Can I add an extra option to createdAt and updatedAt to index it? Thanks.

roymap commented 8 years ago

+1

drudge commented 8 years ago

@juanpujol and @roymap: I've added the ability to pass options when defining the fields to version 0.6.0 on npm:

Example:

var opts = {
    createdAt: {
        name: 'customNameCreatedAt',
        type: String,
        index: true
    },
    updatedAt: {
        name: 'customNameUpdatedAt',
        type: String,
        es_indexed: true
    }
};

var CustomizedTypeOptionsTimeCopSchema = new Schema({
    email: String
});

CustomizedTypeOptionsTimeCopSchema.plugin(timestamps, opts);
CustomizedTypeOptionsTimeCopSchema.plugin(mongoosastic);