deno.land / x / mongoose@6.7.5 / test / types.embeddeddocument.test.js

types.embeddeddocument.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
'use strict';
/** * Module dependencies. */
const start = require('./common');
const assert = require('assert');
const mongoose = start.mongoose;const Schema = mongoose.Schema;
/** * Test. */
describe('types.embeddeddocument', function() { let GrandChildSchema; let ChildSchema; let ParentSchema;
before(function() { GrandChildSchema = new Schema({ name: String });
ChildSchema = new Schema({ name: String, children: [GrandChildSchema] });
ParentSchema = new Schema({ name: String, child: ChildSchema });
mongoose.model('Parent-3589-Embedded', ParentSchema); });
it('returns a proper ownerDocument (gh-3589)', function(done) { const Parent = mongoose.model('Parent-3589-Embedded'); const p = new Parent({ name: 'Parent Parentson', child: { name: 'Child Parentson', children: [ { name: 'GrandChild Parentson' } ] } });
assert.equal(p._id, p.child.children[0].ownerDocument()._id); done(); });});
mongoose

Version Info

Tagged at
a year ago