deno.land / x / mongoose@6.7.5 / test / helpers / indexes.isIndexEqual.test.js

indexes.isIndexEqual.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
'use strict';
const assert = require('assert');const isIndexEqual = require('../../lib/helpers/indexes/isIndexEqual');
describe('isIndexEqual', function() { it('ignores default collation options when comparing collations (gh-8994)', function() { const key = { username: 1 }; const options = { unique: true, collation: { locale: 'en', strength: 2 } }; const dbIndex = { unique: true, key: { username: 1 }, name: 'username_1', background: true, collation: { locale: 'en', caseLevel: false, caseFirst: 'off', strength: 2, numericOrdering: false, version: '57.1' } };
assert.ok(isIndexEqual(key, options, dbIndex));
dbIndex.collation.locale = 'de'; assert.ok(!isIndexEqual(key, options, dbIndex)); });
it('works when MongoDB index has collation but Mongoose index doesn\'t (gh-9224)', function() { const key = { username: 1 }; const options = {}; const dbIndex = { unique: true, key: { username: 1 }, name: 'username_1', background: true, collation: { locale: 'en', caseLevel: false, caseFirst: 'off', strength: 2, numericOrdering: false, version: '57.1' } };
assert.ok(!isIndexEqual(key, options, dbIndex)); });
it('handles text indexes (gh-9225)', function() { const key = { name: 'text' }; const options = {}; const dbIndex = { v: 2, key: { _fts: 'text', _ftsx: 1 }, name: 'name_text', ns: 'test.tests', background: true, weights: { name: 1 }, default_language: 'english', language_override: 'language', textIndexVersion: 3 };
assert.ok(isIndexEqual(key, options, dbIndex));
key.otherProp = 'text'; assert.ok(!isIndexEqual(key, options, dbIndex));
delete key.otherProp; options.weights = { name: 2 }; assert.ok(!isIndexEqual(key, options, dbIndex));
options.weights.name = 1; assert.ok(isIndexEqual(key, options, dbIndex)); });});
mongoose

Version Info

Tagged at
a year ago