Skip to content

Commit 1410dc6

Browse files
committed
Set dates
1 parent ed9fffb commit 1410dc6

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

services/import/src/upsert.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const batch = require('./batch');
33
const client = require('./mongodb');
44

55
const { log } = console;
6-
const now = new Date();
6+
const now = new Date('2022-01-01');
77

88
module.exports = async (records = [], appId, limit = 10) => {
99
log('Upserting ', records.length, appId, limit);
@@ -29,6 +29,8 @@ module.exports = async (records = [], appId, limit = 10) => {
2929
const insertDefaults = {
3030
verified,
3131
customBooleanFieldAnswers,
32+
createdAt: now,
33+
updatedAt: now,
3234
};
3335
const filter = { applicationId, email, ...(_id && { _id }) };
3436
const $addToSet = {
@@ -42,8 +44,8 @@ module.exports = async (records = [], appId, limit = 10) => {
4244
filter,
4345
update: {
4446
...(Object.keys($addToSet).length && { $addToSet }),
45-
$setOnInsert: { ...insertDefaults, ...filter, _importedAt: now },
46-
$set: { ...payload, _updatedAt: now },
47+
$setOnInsert: { ...insertDefaults, ...filter },
48+
$set: { ...payload, _importedAt: now },
4749
},
4850
upsert: !_id,
4951
},

0 commit comments

Comments
 (0)