Closed markstos closed 10 years ago
You can specify custom property names by passing them in as options like this:
mongoose.plugin(timestamps, {
createdAt: 'created_at',
updatedAt: 'updated_at'
});
Thanks for the response.
I'm re-opening this issue because the functionality remains undocumented in the Readme.
Documented.
Custom property names are not working. It is taking default names only. I am giving like this.
var timestamps = require ("mongoose-times");
mongoose.plugin(timestamps, {
createdAt: 'createdDTS',
updatedAt: 'lastModifiedDTS'
});
My response:
"createdAt" : ISODate("2016-05-16T10:02:48.189+0000"),
"updatedAt" : ISODate("2016-05-16T10:02:48.189+0000"),
@penmets Are you using the latest version of the plugin, 0.5.0? When you run "npm test" in the distribution, does it pass? The test suite contains test coverage for custom column names.
If some test coverage seems to be lacking for a case that still fails, please contribute a pull request that adds a new failing test case.
now i insatlled mongoose-timestamp 0.5.0 version. this is my code
var mongoose = require('mongoose'),
Schema = mongoose.Schema,
timestamps = require('mongoose-timestamp');
var MySchema = new mongoose.Schema({
title : String,
media : [{
mediaUrl : String
}]
});
MySchema.plugin(timestamps,{ createdAt: 'createdby',
updatedAt: 'updatedby'});
module.exports = mongoose.model('my', MySchema);
I am gettiong this error , when i am calling create function
TypeError: Cannot read property 'numAsyncPres' of undefined
The string "numAsyncPres" does not appear in this code base. If you think there's a problem with this plugin, add a test case to the test suite to confirm your suspicion.
Thanks for this plugin.
It would be nice if the column names 'updatedAt' and 'createdAt' could be customized.
In our case, we are considering adding it to an existing system where we already have a different naming convention established.