You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, thanks for all your hard work with the great astronomy packages!
I'm trying to seed the database with content. Is there a way to overwrite the created value on save()? Eg, populate the value of the created rather than using the behaviour timestamp when its not defined in the controller. Please see below
var now = new Date();
var lastMonth = new Date();
lastMonth.setMonth(lastMonth.getMonth()-1);
var response = new Response({
score: faker.random.number({ 'min': 0, 'max': 10 }),
created: faker.date.between(lastMonth, now)
});
if (response.validate()) {
response.save();
}
Hmm it may a good improvement. It wouldn't be hard. It would just not override the created field if it's already filled with a value. However it's very important to make it secure. Let's imagine a situation when you're sending a document from the client to the server with the created field already filled by the user on the client. So it should be optional feature.
For now you can just create this field by your self and fill out with a value. You can turn off the createdAt field in behaviors option by setting the hasCreatedField option to false.
Hi, thanks for all your hard work with the great astronomy packages!
I'm trying to seed the database with content. Is there a way to overwrite the created value on save()? Eg, populate the value of the created rather than using the behaviour timestamp when its not defined in the controller. Please see below
Model
Controller
Thanks
Sharry
PS - Works OK with Node & Mongoose with this package:
https://github.com/drudge/mongoose-timestamp
The text was updated successfully, but these errors were encountered: