Skip to content

Commit

Permalink
Add date fields to model database (#252)
Browse files Browse the repository at this point in the history
  • Loading branch information
miltonbsn authored Nov 16, 2021
1 parent 856e500 commit 3e7b830
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions server_app/model/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ let model = mongoose.Schema({
who: { type: String, required: true },
name: { type: String, required: true },
created: { type: Date, default: Date.now },
updated: { type: Date, default: Date.now },
model: { type: Object, required: true },
type: { type: String, required: true },
});
Expand Down
5 changes: 3 additions & 2 deletions server_app/model/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const save = async ({ name, type, model, userId }) => {
type: type,
model: model,
name: name,
updated: Date.now()
});
return resolve(createdModel);
} catch (error) {
Expand All @@ -50,7 +51,7 @@ const edit = async (modelId, model) => {
try {
const response = await modelRepository.updateOne(
{ _id: modelId },
{ $set: { model: model } }
{ $set: { model: model, updated: Date.now() } }
);
if (response.ok) {
return resolve(response);
Expand All @@ -68,7 +69,7 @@ const rename = async (modelId, newName) => {
try {
const response = await modelRepository.updateOne(
{ _id: modelId },
{ $set: { name: newName } }
{ $set: { name: newName, updated: Date.now() } }
);
if (response.ok) {
return resolve(response);
Expand Down
3 changes: 2 additions & 1 deletion server_app/user/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const userSchema = new Schema({
login: { type: String },
name: { type: String },
password: { type: String },
recoveryCode: { type: String }
recoveryCode: { type: String },
created: { type: Date, default: Date.now },
});

module.exports = mongoose.model("User", userSchema);

0 comments on commit 3e7b830

Please sign in to comment.