mirror of
https://github.com/strapi/strapi.git
synced 2025-12-28 15:44:59 +00:00
Exclude timestamps on save and updates in queries
This commit is contained in:
parent
c17a718f25
commit
472553b3b2
@ -2,6 +2,13 @@ services:
|
||||
- postgresql
|
||||
- mysql
|
||||
|
||||
addons:
|
||||
postgresql: '10'
|
||||
apt:
|
||||
packages:
|
||||
- postgresql-10
|
||||
- postgresql-client-10
|
||||
|
||||
sudo: required
|
||||
dist: trusty
|
||||
|
||||
|
||||
@ -19,6 +19,8 @@ module.exports = function createQueryBuilder({ model, modelKey, strapi }) {
|
||||
return model.attributes[key].type === 'group';
|
||||
});
|
||||
|
||||
const timestamps = _.get(model, ['options', 'timestamps'], []);
|
||||
|
||||
// Returns an object with relation keys only to create relations in DB
|
||||
const pickRelations = values => {
|
||||
return _.pick(values, assocKeys);
|
||||
@ -29,6 +31,10 @@ module.exports = function createQueryBuilder({ model, modelKey, strapi }) {
|
||||
// Returns an object without relational keys to persist in DB
|
||||
const selectAttributes = values => {
|
||||
return _.pickBy(values, (value, key) => {
|
||||
if (Array.isArray(timestamps) && timestamps.includes(key)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !excludedKeys.includes(key) && _.has(model.allAttributes, key);
|
||||
});
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user