deno.land / x / mongoose@6.7.5 / test / helpers / update.applyTimestampsToChildren.test.js

update.applyTimestampsToChildren.test.js
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
'use strict';
const Schema = require('../../lib/schema');const applyTimestampsToChildren = require('../../lib/helpers/update/applyTimestampsToChildren');const assert = require('assert');
describe('applyTimestampsToChildren', function() { it('applies timestamps to nested subdocs within a $push (gh-11775)', function() { const update = { $push: { l1: { l2: { prop: 'test' } } } }; const now = new Date('2016-01-01'); const schema = new Schema({ l1: [new Schema({ l2: new Schema({ prop: String }, { timestamps: true }) }, { timestamps: true })] }); applyTimestampsToChildren(now, update, schema);
assert.equal(update.$push.l1.l2.createdAt.valueOf(), now.valueOf()); assert.equal(update.$push.l1.l2.updatedAt.valueOf(), now.valueOf()); });});
mongoose

Version Info

Tagged at
a year ago