mirror of
https://github.com/JonasunderscoreJones/jonas_jones-api.git
synced 2025-10-24 17:49:18 +02:00
some progress
This commit is contained in:
parent
aea93a5527
commit
e3c15bd288
1388 changed files with 306946 additions and 68323 deletions
26
node_modules/mongoose/lib/helpers/timestamps/setDocumentTimestamps.js
generated
vendored
Normal file
26
node_modules/mongoose/lib/helpers/timestamps/setDocumentTimestamps.js
generated
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = function setDocumentTimestamps(doc, timestampOption, currentTime, createdAt, updatedAt) {
|
||||
const skipUpdatedAt = timestampOption != null && timestampOption.updatedAt === false;
|
||||
const skipCreatedAt = timestampOption != null && timestampOption.createdAt === false;
|
||||
|
||||
const defaultTimestamp = currentTime != null ?
|
||||
currentTime() :
|
||||
doc.ownerDocument().constructor.base.now();
|
||||
|
||||
if (!skipCreatedAt &&
|
||||
(doc.isNew || doc.$isSubdocument) &&
|
||||
createdAt &&
|
||||
!doc.$__getValue(createdAt) &&
|
||||
doc.$__isSelected(createdAt)) {
|
||||
doc.$set(createdAt, defaultTimestamp, undefined, { overwriteImmutable: true });
|
||||
}
|
||||
|
||||
if (!skipUpdatedAt && updatedAt && (doc.isNew || doc.$isModified())) {
|
||||
let ts = defaultTimestamp;
|
||||
if (doc.isNew && createdAt != null) {
|
||||
ts = doc.$__getValue(createdAt);
|
||||
}
|
||||
doc.$set(updatedAt, ts);
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue