1 year ago
#300765

Ryan Garde
Automatically update a column on insert - ObjectionJS
I want to automatically update the CreatedDateTime
column whenever I want to insert or update column. But my problem is some tables have no CreatedDateTime
column.
My code looks like this:
$beforeInsert(context) {
this.CreatedDateTime = new Date().toISOString();
}
I tried explicitly specified the json schema like this:
static get jsonSchema() {
return {
type: 'object',
properties: {
CanteenFreeMealLineID: {
type: 'integer',
},
CanteenFreeMealID: {
type: 'integer',
},
DatacenterID: {
type: 'integer',
},
},
};
}
but it still forces to update to column CreatedDateTime
javascript
mysql
node.js
knex.js
objection.js
0 Answers
Your Answer