Skip to content

Commit

Permalink
feat(tasks,users): add createAt updateAt ✨
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreBrisorgueil committed May 21, 2019
1 parent fd0ddb8 commit d63699e
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion config/defaults/development.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ module.exports = {
},
whitelists: {
users: {
default: ['_id', 'id', 'firstName', 'lastName', 'displayName', 'username', 'email', 'roles', 'profileImageURL', 'updated', 'created', 'resetPasswordToken', 'resetPasswordExpires'],
default: ['_id', 'id', 'firstName', 'lastName', 'displayName', 'username', 'email', 'roles', 'profileImageURL', 'resetPasswordToken', 'resetPasswordExpires'],
update: ['firstName', 'lastName', 'username', 'email', 'profileImageURL'],
updateAdmin: ['firstName', 'lastName', 'username', 'email', 'profileImageURL', 'roles'],
recover: ['password', 'resetPasswordToken', 'resetPasswordExpires'],
Expand Down
2 changes: 2 additions & 0 deletions modules/tasks/models/tasks.model.mongoose.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ const TaskMongoose = new Schema({
type: Schema.ObjectId,
ref: 'User',
},
}, {
timestamps: true,
});

/**
Expand Down
2 changes: 1 addition & 1 deletion modules/tasks/repositories/tasks.repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const Task = mongoose.model('Task');
* @desc Function to get all task in db
* @return {Array} All tasks
*/
exports.list = () => Task.find().sort('-created').exec();
exports.list = () => Task.find().sort('-createdAt').exec();

/**
* @desc Function to create a task in db
Expand Down
5 changes: 2 additions & 3 deletions modules/users/models/user.model.mongoose.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ const UserMongoose = new Schema({
},
profileImageURL: String,
roles: [],
/* Extra */
updated: Date,
created: Date,
/* Provider */
provider: String,
providerData: {},
Expand All @@ -35,6 +32,8 @@ const UserMongoose = new Schema({
password: String,
resetPasswordToken: String,
resetPasswordExpires: Date,
}, {
timestamps: true,
});

// add virtual id field (FIXME mongoose.virtual ko es6)
Expand Down
2 changes: 1 addition & 1 deletion modules/users/repositories/user.repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const User = mongoose.model('User');
* @desc Function to get all user in db
* @return {Array} All users
*/
exports.list = () => User.find({}, '-password -providerData').sort('-created').exec();
exports.list = () => User.find({}, '-password -providerData').sort('-createdAt').exec();

/**
* @desc Function to create a user in db
Expand Down

0 comments on commit d63699e

Please sign in to comment.