created_at field always updated when call save() method
See original GitHub issueUserController.js
"use strict";
const User = use("App/Models/User");
const Hash = use("Hash");
class UserController {
async store() {
const user = new User();
user.username = "abc";
user.email = "abc@gmail.com";
user.password = await Hash.make("abc");
return await user.save();
}
async show({ params }) {
const { id } = params;
return await User.find(id);
}
async update({ params }) {
const { id } = params;
const user = await User.find(id);
user.username = "abc";
user.email = "abc@gmail.com";
user.password = await Hash.make("abc");
return await user.save();
}
}
module.exports = UserController;
I’m using fresh install of adonis, and mssql
Azure
as the database connection
after saving data using save() the created_at field updated to another value, check my video
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (3 by maintainers)
Top Results From Across the Web
add created_at and updated_at fields to mongoose schemas
The created_at field would be a date and only added when a document is created. The updated_at field would be updated with new...
Read more >How to persist creation and update timestamps with ...
You need a simple, fail-safe solution that automatically updates the timestamp for each and every change. As so often, there are multiple ways...
Read more >How to update createdAt and updatedAt fields in your data ...
One solution would be to have an "Update Audit Fields" node in your process model before your data write. Here, you could save...
Read more >JavaScript Developers Guide | Parse
Updating an object is simple. Just set some new data on it and call the save method. For example: // Create the object....
Read more >Django Tips #4 Automatic DateTime Fields
The auto_now_add will set the timezone.now() only when the instance is created, and auto_now will update the field everytime the save method is ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I fixed using this:
I have this same problem … I am using MSSQL and saving the records using the save () method. apparently when creating the record it saves with the correct dates … but in the update process the new dates no longer match … it also changes the created_at date whenever the save () method is executed …