@e22m4u/js-repository-mongodb-adapter 0.5.6 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/cjs/index.cjs +843 -37
- package/package.json +2 -2
- package/src/mongodb-adapter.js +18 -4
- package/src/mongodb-adapter.spec.js +361 -147
- package/src/utils/index.js +3 -0
- package/src/utils/model-name-to-collection-name.js +26 -0
- package/src/utils/model-name-to-collection-name.spec.js +89 -0
- package/src/utils/pluralize.js +63 -0
- package/src/utils/pluralize.spec.js +110 -0
- package/src/utils/to-camel-case.js +18 -0
- package/src/utils/to-camel-case.spec.js +75 -0
|
@@ -42,6 +42,214 @@ describe('MongodbAdapter', function () {
|
|
|
42
42
|
await MDB_CLIENT.close(true);
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
+
describe('_getCollectionNameByModelName', function () {
|
|
46
|
+
it('converts model name to camel case and pluralizes it', async function () {
|
|
47
|
+
const schema = createSchema();
|
|
48
|
+
const modelNamesToCollectionNames = [
|
|
49
|
+
['camelCaseEntity', 'camelCaseEntities'],
|
|
50
|
+
['PascalCaseEntity', 'pascalCaseEntities'],
|
|
51
|
+
['snake_case_entity', 'snakeCaseEntities'],
|
|
52
|
+
['kebab-case-entity', 'kebabCaseEntities'],
|
|
53
|
+
['UPPER_SNAKE_CASE_ENTITY', 'upperSnakeCaseEntities'],
|
|
54
|
+
['UPPER-KEBAB-CASE-ENTITY', 'upperKebabCaseEntities'],
|
|
55
|
+
];
|
|
56
|
+
modelNamesToCollectionNames.forEach(tuple =>
|
|
57
|
+
schema.defineModel({name: tuple[0], datasource: 'mongodb'}),
|
|
58
|
+
);
|
|
59
|
+
const A = await schema.getService(AdapterRegistry).getAdapter('mongodb');
|
|
60
|
+
modelNamesToCollectionNames.forEach(tuple =>
|
|
61
|
+
expect(A._getCollectionNameByModelName(tuple[0])).to.be.eq(tuple[1]),
|
|
62
|
+
);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// prettier-ignore
|
|
66
|
+
it('cuts off the "Model" suffix from the model name', async function () {
|
|
67
|
+
const schema = createSchema();
|
|
68
|
+
const modelNamesToCollectionNames = [
|
|
69
|
+
['camelCaseEntityModel', 'camelCaseEntities'],
|
|
70
|
+
['PascalCaseEntityModel', 'pascalCaseEntities'],
|
|
71
|
+
['snake_case_entity_model', 'snakeCaseEntities'],
|
|
72
|
+
['kebab-case-entity-model', 'kebabCaseEntities'],
|
|
73
|
+
['UPPER_SNAKE_CASE_ENTITY_MODEL', 'upperSnakeCaseEntities'],
|
|
74
|
+
['UPPER-KEBAB-CASE-ENTITY-MODEL', 'upperKebabCaseEntities'],
|
|
75
|
+
];
|
|
76
|
+
modelNamesToCollectionNames.forEach(tuple =>
|
|
77
|
+
schema.defineModel({name: tuple[0], datasource: 'mongodb'}),
|
|
78
|
+
);
|
|
79
|
+
const A = await schema.getService(AdapterRegistry).getAdapter('mongodb');
|
|
80
|
+
modelNamesToCollectionNames.forEach(tuple =>
|
|
81
|
+
expect(A._getCollectionNameByModelName(tuple[0])).to.be.eq(tuple[1]),
|
|
82
|
+
);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('converts already pluralized model name to camel case', async function () {
|
|
86
|
+
const schema = createSchema();
|
|
87
|
+
const modelNamesToCollectionNames = [
|
|
88
|
+
['camelCaseEntities', 'camelCaseEntities'],
|
|
89
|
+
['PascalCaseEntities', 'pascalCaseEntities'],
|
|
90
|
+
['snake_case_entities', 'snakeCaseEntities'],
|
|
91
|
+
['kebab-case-entities', 'kebabCaseEntities'],
|
|
92
|
+
['UPPER_SNAKE_CASE_ENTITIES', 'upperSnakeCaseEntities'],
|
|
93
|
+
['UPPER-KEBAB-CASE-ENTITIES', 'upperKebabCaseEntities'],
|
|
94
|
+
];
|
|
95
|
+
modelNamesToCollectionNames.forEach(tuple =>
|
|
96
|
+
schema.defineModel({name: tuple[0], datasource: 'mongodb'}),
|
|
97
|
+
);
|
|
98
|
+
const A = await schema.getService(AdapterRegistry).getAdapter('mongodb');
|
|
99
|
+
modelNamesToCollectionNames.forEach(tuple =>
|
|
100
|
+
expect(A._getCollectionNameByModelName(tuple[0])).to.be.eq(tuple[1]),
|
|
101
|
+
);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// prettier-ignore
|
|
105
|
+
it('converts already pluralized model name to camel case and cut off the "Model" suffix', async function () {
|
|
106
|
+
const schema = createSchema();
|
|
107
|
+
const modelNamesToCollectionNames = [
|
|
108
|
+
['camelCaseEntitiesModel', 'camelCaseEntities'],
|
|
109
|
+
['PascalCaseEntitiesModel', 'pascalCaseEntities'],
|
|
110
|
+
['snake_case_entities_model', 'snakeCaseEntities'],
|
|
111
|
+
['kebab-case-entities-model', 'kebabCaseEntities'],
|
|
112
|
+
['UPPER_SNAKE_CASE_ENTITIES_MODEL', 'upperSnakeCaseEntities'],
|
|
113
|
+
['UPPER-KEBAB-CASE-ENTITIES-MODEL', 'upperKebabCaseEntities'],
|
|
114
|
+
];
|
|
115
|
+
modelNamesToCollectionNames.forEach(tuple =>
|
|
116
|
+
schema.defineModel({name: tuple[0], datasource: 'mongodb'}),
|
|
117
|
+
);
|
|
118
|
+
const A = await schema.getService(AdapterRegistry).getAdapter('mongodb');
|
|
119
|
+
modelNamesToCollectionNames.forEach(tuple =>
|
|
120
|
+
expect(A._getCollectionNameByModelName(tuple[0])).to.be.eq(tuple[1]),
|
|
121
|
+
);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('returns the value from the "tableName" option if defined', async function () {
|
|
125
|
+
const schema = createSchema();
|
|
126
|
+
schema.defineModel({
|
|
127
|
+
name: 'fooBar',
|
|
128
|
+
tableName: 'bazQux',
|
|
129
|
+
datasource: 'mongodb',
|
|
130
|
+
});
|
|
131
|
+
const A = await schema.getService(AdapterRegistry).getAdapter('mongodb');
|
|
132
|
+
expect(A._getCollectionNameByModelName('fooBar')).to.be.eq('bazQux');
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
describe('_getCollection', function () {
|
|
137
|
+
it('should create and return a new collection object on the first call', async function () {
|
|
138
|
+
const schema = createSchema();
|
|
139
|
+
schema.defineModel({name: 'myTestModel', datasource: 'mongodb'});
|
|
140
|
+
const A = await schema.getService(AdapterRegistry).getAdapter('mongodb');
|
|
141
|
+
expect(A._collections.has('myTestModel')).to.be.false;
|
|
142
|
+
const collection = A._getCollection('myTestModel');
|
|
143
|
+
expect(collection).to.exist;
|
|
144
|
+
expect(collection.collectionName).to.equal('myTests');
|
|
145
|
+
expect(collection.dbName).to.equal(CONFIG.database);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it('should cache the collection object after the first call', async function () {
|
|
149
|
+
const schema = createSchema();
|
|
150
|
+
schema.defineModel({name: 'myTestModel', datasource: 'mongodb'});
|
|
151
|
+
const A = await schema.getService(AdapterRegistry).getAdapter('mongodb');
|
|
152
|
+
expect(A._collections.has('myTestModel')).to.be.false;
|
|
153
|
+
A._getCollection('myTestModel');
|
|
154
|
+
expect(A._collections.has('myTestModel')).to.be.true;
|
|
155
|
+
expect(A._collections.get('myTestModel')).to.exist;
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it('should return the cached collection instance on subsequent calls', async function () {
|
|
159
|
+
const schema = createSchema();
|
|
160
|
+
schema.defineModel({name: 'myTestModel', datasource: 'mongodb'});
|
|
161
|
+
const A = await schema.getService(AdapterRegistry).getAdapter('mongodb');
|
|
162
|
+
const collection1 = A._getCollection('myTestModel');
|
|
163
|
+
const collection2 = A._getCollection('myTestModel');
|
|
164
|
+
expect(collection2).to.equal(collection1);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it('converts model name to camel case and pluralizes it', async function () {
|
|
168
|
+
const schema = createSchema();
|
|
169
|
+
const modelNamesToCollectionNames = [
|
|
170
|
+
['camelCaseEntity', 'camelCaseEntities'],
|
|
171
|
+
['PascalCaseEntity', 'pascalCaseEntities'],
|
|
172
|
+
['snake_case_entity', 'snakeCaseEntities'],
|
|
173
|
+
['kebab-case-entity', 'kebabCaseEntities'],
|
|
174
|
+
['UPPER_SNAKE_CASE_ENTITY', 'upperSnakeCaseEntities'],
|
|
175
|
+
['UPPER-KEBAB-CASE-ENTITY', 'upperKebabCaseEntities'],
|
|
176
|
+
];
|
|
177
|
+
const A = await schema.getService(AdapterRegistry).getAdapter('mongodb');
|
|
178
|
+
modelNamesToCollectionNames.forEach(tuple => {
|
|
179
|
+
schema.defineModel({name: tuple[0], datasource: 'mongodb'});
|
|
180
|
+
const collection = A._getCollection(tuple[0]);
|
|
181
|
+
expect(collection.collectionName).to.equal(tuple[1]);
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it('cuts off the "Model" suffix from the model name', async function () {
|
|
186
|
+
const schema = createSchema();
|
|
187
|
+
const modelNamesToCollectionNames = [
|
|
188
|
+
['camelCaseEntityModel', 'camelCaseEntities'],
|
|
189
|
+
['PascalCaseEntityModel', 'pascalCaseEntities'],
|
|
190
|
+
['snake_case_entity_model', 'snakeCaseEntities'],
|
|
191
|
+
['kebab-case-entity-model', 'kebabCaseEntities'],
|
|
192
|
+
['UPPER_SNAKE_CASE_ENTITY_MODEL', 'upperSnakeCaseEntities'],
|
|
193
|
+
['UPPER-KEBAB-CASE-ENTITY-MODEL', 'upperKebabCaseEntities'],
|
|
194
|
+
];
|
|
195
|
+
const A = await schema.getService(AdapterRegistry).getAdapter('mongodb');
|
|
196
|
+
modelNamesToCollectionNames.forEach(tuple => {
|
|
197
|
+
schema.defineModel({name: tuple[0], datasource: 'mongodb'});
|
|
198
|
+
const collection = A._getCollection(tuple[0]);
|
|
199
|
+
expect(collection.collectionName).to.equal(tuple[1]);
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it('converts already pluralized model name to camel case', async function () {
|
|
204
|
+
const schema = createSchema();
|
|
205
|
+
const modelNamesToCollectionNames = [
|
|
206
|
+
['camelCaseEntities', 'camelCaseEntities'],
|
|
207
|
+
['PascalCaseEntities', 'pascalCaseEntities'],
|
|
208
|
+
['snake_case_entities', 'snakeCaseEntities'],
|
|
209
|
+
['kebab-case-entities', 'kebabCaseEntities'],
|
|
210
|
+
['UPPER_SNAKE_CASE_ENTITIES', 'upperSnakeCaseEntities'],
|
|
211
|
+
['UPPER-KEBAB-CASE-ENTITIES', 'upperKebabCaseEntities'],
|
|
212
|
+
];
|
|
213
|
+
const A = await schema.getService(AdapterRegistry).getAdapter('mongodb');
|
|
214
|
+
modelNamesToCollectionNames.forEach(tuple => {
|
|
215
|
+
schema.defineModel({name: tuple[0], datasource: 'mongodb'});
|
|
216
|
+
const collection = A._getCollection(tuple[0]);
|
|
217
|
+
expect(collection.collectionName).to.equal(tuple[1]);
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it('converts already pluralized model name to camel case and cut off the "Model" suffix', async function () {
|
|
222
|
+
const schema = createSchema();
|
|
223
|
+
const modelNamesToCollectionNames = [
|
|
224
|
+
['camelCaseEntitiesModel', 'camelCaseEntities'],
|
|
225
|
+
['PascalCaseEntitiesModel', 'pascalCaseEntities'],
|
|
226
|
+
['snake_case_entities_model', 'snakeCaseEntities'],
|
|
227
|
+
['kebab-case-entities-model', 'kebabCaseEntities'],
|
|
228
|
+
['UPPER_SNAKE_CASE_ENTITIES_MODEL', 'upperSnakeCaseEntities'],
|
|
229
|
+
['UPPER-KEBAB-CASE-ENTITIES-MODEL', 'upperKebabCaseEntities'],
|
|
230
|
+
];
|
|
231
|
+
const A = await schema.getService(AdapterRegistry).getAdapter('mongodb');
|
|
232
|
+
modelNamesToCollectionNames.forEach(tuple => {
|
|
233
|
+
schema.defineModel({name: tuple[0], datasource: 'mongodb'});
|
|
234
|
+
const collection = A._getCollection(tuple[0]);
|
|
235
|
+
expect(collection.collectionName).to.equal(tuple[1]);
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
it('uses the value from the "tableName" option if defined', async function () {
|
|
240
|
+
const schema = createSchema();
|
|
241
|
+
const A = await schema.getService(AdapterRegistry).getAdapter('mongodb');
|
|
242
|
+
const customTableName = 'custom_baz_qux';
|
|
243
|
+
schema.defineModel({
|
|
244
|
+
name: 'fooBar',
|
|
245
|
+
tableName: customTableName,
|
|
246
|
+
datasource: 'mongodb',
|
|
247
|
+
});
|
|
248
|
+
const collection = A._getCollection('fooBar');
|
|
249
|
+
expect(collection.collectionName).to.equal(customTableName);
|
|
250
|
+
});
|
|
251
|
+
});
|
|
252
|
+
|
|
45
253
|
describe('_buildProjection', function () {
|
|
46
254
|
describe('single field', function () {
|
|
47
255
|
it('returns undefined if the second argument is undefined', async function () {
|
|
@@ -1480,7 +1688,7 @@ describe('MongodbAdapter', function () {
|
|
|
1480
1688
|
const result = await rep.create({[DEF_PK]: oid});
|
|
1481
1689
|
expect(result).to.be.eql({[DEF_PK]: String(oid)});
|
|
1482
1690
|
const rawData = await MDB_CLIENT.db()
|
|
1483
|
-
.collection('
|
|
1691
|
+
.collection('models')
|
|
1484
1692
|
.findOne({_id: oid});
|
|
1485
1693
|
expect(rawData).to.be.not.null;
|
|
1486
1694
|
});
|
|
@@ -1494,7 +1702,7 @@ describe('MongodbAdapter', function () {
|
|
|
1494
1702
|
const result = await rep.create({[DEF_PK]: id});
|
|
1495
1703
|
expect(result).to.be.eql({[DEF_PK]: id});
|
|
1496
1704
|
const rawData = await MDB_CLIENT.db()
|
|
1497
|
-
.collection('
|
|
1705
|
+
.collection('models')
|
|
1498
1706
|
.findOne({_id: oid});
|
|
1499
1707
|
expect(rawData).to.be.not.null;
|
|
1500
1708
|
});
|
|
@@ -1516,7 +1724,7 @@ describe('MongodbAdapter', function () {
|
|
|
1516
1724
|
const result = await rep.create({id: oid});
|
|
1517
1725
|
expect(result).to.be.eql({id: String(oid)});
|
|
1518
1726
|
const rawData = await MDB_CLIENT.db()
|
|
1519
|
-
.collection('
|
|
1727
|
+
.collection('models')
|
|
1520
1728
|
.findOne({_id: oid});
|
|
1521
1729
|
expect(rawData).to.be.not.null;
|
|
1522
1730
|
});
|
|
@@ -1539,7 +1747,7 @@ describe('MongodbAdapter', function () {
|
|
|
1539
1747
|
const result = await rep.create({id});
|
|
1540
1748
|
expect(result).to.be.eql({id});
|
|
1541
1749
|
const rawData = await MDB_CLIENT.db()
|
|
1542
|
-
.collection('
|
|
1750
|
+
.collection('models')
|
|
1543
1751
|
.findOne({_id: oid});
|
|
1544
1752
|
expect(rawData).to.be.not.null;
|
|
1545
1753
|
});
|
|
@@ -1561,7 +1769,7 @@ describe('MongodbAdapter', function () {
|
|
|
1561
1769
|
const result = await rep.create({_id: oid});
|
|
1562
1770
|
expect(result).to.be.eql({_id: String(oid)});
|
|
1563
1771
|
const rawData = await MDB_CLIENT.db()
|
|
1564
|
-
.collection('
|
|
1772
|
+
.collection('models')
|
|
1565
1773
|
.findOne({_id: oid});
|
|
1566
1774
|
expect(rawData).to.be.not.null;
|
|
1567
1775
|
});
|
|
@@ -1584,7 +1792,7 @@ describe('MongodbAdapter', function () {
|
|
|
1584
1792
|
const result = await rep.create({_id: id});
|
|
1585
1793
|
expect(result).to.be.eql({_id: id});
|
|
1586
1794
|
const rawData = await MDB_CLIENT.db()
|
|
1587
|
-
.collection('
|
|
1795
|
+
.collection('models')
|
|
1588
1796
|
.findOne({_id: oid});
|
|
1589
1797
|
expect(rawData).to.be.not.null;
|
|
1590
1798
|
});
|
|
@@ -1616,10 +1824,13 @@ describe('MongodbAdapter', function () {
|
|
|
1616
1824
|
const rep = schema.getRepository('model');
|
|
1617
1825
|
await rep.create({[DEF_PK]: 10});
|
|
1618
1826
|
const promise = rep.create({[DEF_PK]: 10});
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
)
|
|
1827
|
+
try {
|
|
1828
|
+
await promise;
|
|
1829
|
+
expect.fail('Promise should have been rejected');
|
|
1830
|
+
} catch (error) {
|
|
1831
|
+
expect(error.name).to.equal('MongoServerError');
|
|
1832
|
+
expect(error.code).to.equal(11000);
|
|
1833
|
+
}
|
|
1623
1834
|
});
|
|
1624
1835
|
|
|
1625
1836
|
it('throws an error if a given "string" identifier already exists', async function () {
|
|
@@ -1628,10 +1839,13 @@ describe('MongodbAdapter', function () {
|
|
|
1628
1839
|
const rep = schema.getRepository('model');
|
|
1629
1840
|
await rep.create({[DEF_PK]: 'str'});
|
|
1630
1841
|
const promise = rep.create({[DEF_PK]: 'str'});
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
)
|
|
1842
|
+
try {
|
|
1843
|
+
await promise;
|
|
1844
|
+
expect.fail('Promise should have been rejected');
|
|
1845
|
+
} catch (error) {
|
|
1846
|
+
expect(error.name).to.equal('MongoServerError');
|
|
1847
|
+
expect(error.code).to.equal(11000);
|
|
1848
|
+
}
|
|
1635
1849
|
});
|
|
1636
1850
|
|
|
1637
1851
|
it('throws an error if a given ObjectId instance identifier already exists', async function () {
|
|
@@ -1641,13 +1855,13 @@ describe('MongodbAdapter', function () {
|
|
|
1641
1855
|
const oid = new ObjectId();
|
|
1642
1856
|
await rep.create({[DEF_PK]: oid});
|
|
1643
1857
|
const promise = rep.create({[DEF_PK]: oid});
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
)
|
|
1650
|
-
|
|
1858
|
+
try {
|
|
1859
|
+
await promise;
|
|
1860
|
+
expect.fail('Promise should have been rejected');
|
|
1861
|
+
} catch (error) {
|
|
1862
|
+
expect(error.name).to.equal('MongoServerError');
|
|
1863
|
+
expect(error.code).to.equal(11000);
|
|
1864
|
+
}
|
|
1651
1865
|
});
|
|
1652
1866
|
|
|
1653
1867
|
it('throws an error if a given ObjectId string identifier already exists', async function () {
|
|
@@ -1658,13 +1872,13 @@ describe('MongodbAdapter', function () {
|
|
|
1658
1872
|
const id = String(oid);
|
|
1659
1873
|
await rep.create({[DEF_PK]: id});
|
|
1660
1874
|
const promise = rep.create({[DEF_PK]: id});
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
)
|
|
1667
|
-
|
|
1875
|
+
try {
|
|
1876
|
+
await promise;
|
|
1877
|
+
expect.fail('Promise should have been rejected');
|
|
1878
|
+
} catch (error) {
|
|
1879
|
+
expect(error.name).to.equal('MongoServerError');
|
|
1880
|
+
expect(error.code).to.equal(11000);
|
|
1881
|
+
}
|
|
1668
1882
|
});
|
|
1669
1883
|
|
|
1670
1884
|
it('uses a specified column name for a regular property', async function () {
|
|
@@ -1684,7 +1898,7 @@ describe('MongodbAdapter', function () {
|
|
|
1684
1898
|
expect(result).to.be.eql({[DEF_PK]: result[DEF_PK], foo: 10});
|
|
1685
1899
|
const oid = new ObjectId(result[DEF_PK]);
|
|
1686
1900
|
const rawData = await MDB_CLIENT.db()
|
|
1687
|
-
.collection('
|
|
1901
|
+
.collection('models')
|
|
1688
1902
|
.findOne({_id: oid});
|
|
1689
1903
|
expect(rawData).to.be.eql({_id: oid, bar: 10});
|
|
1690
1904
|
});
|
|
@@ -1707,7 +1921,7 @@ describe('MongodbAdapter', function () {
|
|
|
1707
1921
|
expect(result).to.be.eql({[DEF_PK]: result[DEF_PK], foo: 10});
|
|
1708
1922
|
const oid = new ObjectId(result[DEF_PK]);
|
|
1709
1923
|
const rawData = await MDB_CLIENT.db()
|
|
1710
|
-
.collection('
|
|
1924
|
+
.collection('models')
|
|
1711
1925
|
.findOne({_id: oid});
|
|
1712
1926
|
expect(rawData).to.be.eql({_id: oid, bar: 10});
|
|
1713
1927
|
});
|
|
@@ -1722,7 +1936,7 @@ describe('MongodbAdapter', function () {
|
|
|
1722
1936
|
expect(result).to.be.eql({[DEF_PK]: result[DEF_PK], date: dateString});
|
|
1723
1937
|
const oid = new ObjectId(result[DEF_PK]);
|
|
1724
1938
|
const rawData = await MDB_CLIENT.db()
|
|
1725
|
-
.collection('
|
|
1939
|
+
.collection('models')
|
|
1726
1940
|
.findOne({_id: oid});
|
|
1727
1941
|
expect(rawData).to.be.eql({_id: oid, date});
|
|
1728
1942
|
});
|
|
@@ -1737,7 +1951,7 @@ describe('MongodbAdapter', function () {
|
|
|
1737
1951
|
expect(result).to.be.eql({[DEF_PK]: result[DEF_PK], date: dateString});
|
|
1738
1952
|
const oid = new ObjectId(result[DEF_PK]);
|
|
1739
1953
|
const rawData = await MDB_CLIENT.db()
|
|
1740
|
-
.collection('
|
|
1954
|
+
.collection('models')
|
|
1741
1955
|
.findOne({_id: oid});
|
|
1742
1956
|
expect(rawData).to.be.eql({_id: oid, date});
|
|
1743
1957
|
});
|
|
@@ -1750,7 +1964,7 @@ describe('MongodbAdapter', function () {
|
|
|
1750
1964
|
expect(result).to.be.eql({[DEF_PK]: result[DEF_PK], foo: 'str'});
|
|
1751
1965
|
const oid = new ObjectId(result[DEF_PK]);
|
|
1752
1966
|
const rawData = await MDB_CLIENT.db()
|
|
1753
|
-
.collection('
|
|
1967
|
+
.collection('models')
|
|
1754
1968
|
.findOne({_id: oid});
|
|
1755
1969
|
expect(rawData).to.be.eql({_id: oid, foo: 'str'});
|
|
1756
1970
|
});
|
|
@@ -1763,7 +1977,7 @@ describe('MongodbAdapter', function () {
|
|
|
1763
1977
|
expect(result).to.be.eql({[DEF_PK]: result[DEF_PK], foo: 10});
|
|
1764
1978
|
const oid = new ObjectId(result[DEF_PK]);
|
|
1765
1979
|
const rawData = await MDB_CLIENT.db()
|
|
1766
|
-
.collection('
|
|
1980
|
+
.collection('models')
|
|
1767
1981
|
.findOne({_id: oid});
|
|
1768
1982
|
expect(rawData).to.be.eql({_id: oid, foo: 10});
|
|
1769
1983
|
});
|
|
@@ -1780,7 +1994,7 @@ describe('MongodbAdapter', function () {
|
|
|
1780
1994
|
});
|
|
1781
1995
|
const oid = new ObjectId(result[DEF_PK]);
|
|
1782
1996
|
const rawData = await MDB_CLIENT.db()
|
|
1783
|
-
.collection('
|
|
1997
|
+
.collection('models')
|
|
1784
1998
|
.findOne({_id: oid});
|
|
1785
1999
|
expect(rawData).to.be.eql({_id: oid, foo: true, bar: false});
|
|
1786
2000
|
});
|
|
@@ -1796,7 +2010,7 @@ describe('MongodbAdapter', function () {
|
|
|
1796
2010
|
});
|
|
1797
2011
|
const oid = new ObjectId(result[DEF_PK]);
|
|
1798
2012
|
const rawData = await MDB_CLIENT.db()
|
|
1799
|
-
.collection('
|
|
2013
|
+
.collection('models')
|
|
1800
2014
|
.findOne({_id: oid});
|
|
1801
2015
|
expect(rawData).to.be.eql({_id: oid, foo: ['bar']});
|
|
1802
2016
|
});
|
|
@@ -1812,7 +2026,7 @@ describe('MongodbAdapter', function () {
|
|
|
1812
2026
|
});
|
|
1813
2027
|
const oid = new ObjectId(result[DEF_PK]);
|
|
1814
2028
|
const rawData = await MDB_CLIENT.db()
|
|
1815
|
-
.collection('
|
|
2029
|
+
.collection('models')
|
|
1816
2030
|
.findOne({_id: oid});
|
|
1817
2031
|
expect(rawData).to.be.eql({_id: oid, foo: {bar: 10}});
|
|
1818
2032
|
});
|
|
@@ -1828,7 +2042,7 @@ describe('MongodbAdapter', function () {
|
|
|
1828
2042
|
});
|
|
1829
2043
|
const oid = new ObjectId(result[DEF_PK]);
|
|
1830
2044
|
const rawData = await MDB_CLIENT.db()
|
|
1831
|
-
.collection('
|
|
2045
|
+
.collection('models')
|
|
1832
2046
|
.findOne({_id: oid});
|
|
1833
2047
|
expect(rawData).to.be.eql({_id: oid, foo: null});
|
|
1834
2048
|
});
|
|
@@ -1844,7 +2058,7 @@ describe('MongodbAdapter', function () {
|
|
|
1844
2058
|
});
|
|
1845
2059
|
const oid = new ObjectId(result[DEF_PK]);
|
|
1846
2060
|
const rawData = await MDB_CLIENT.db()
|
|
1847
|
-
.collection('
|
|
2061
|
+
.collection('models')
|
|
1848
2062
|
.findOne({_id: oid});
|
|
1849
2063
|
expect(rawData).to.be.eql({_id: oid, foo: null});
|
|
1850
2064
|
});
|
|
@@ -1868,7 +2082,7 @@ describe('MongodbAdapter', function () {
|
|
|
1868
2082
|
expect(result).to.be.eql({[DEF_PK]: result[DEF_PK], foo: 10, bar: 20});
|
|
1869
2083
|
const oid = new ObjectId(result[DEF_PK]);
|
|
1870
2084
|
const rawData = await MDB_CLIENT.db()
|
|
1871
|
-
.collection('
|
|
2085
|
+
.collection('models')
|
|
1872
2086
|
.findOne({_id: oid});
|
|
1873
2087
|
expect(rawData).to.be.eql({_id: oid, foo: 10, bar: 20, baz: 30});
|
|
1874
2088
|
});
|
|
@@ -1913,7 +2127,7 @@ describe('MongodbAdapter', function () {
|
|
|
1913
2127
|
expect(replaced).to.be.eql({[DEF_PK]: id, bar: 20});
|
|
1914
2128
|
const oid = new ObjectId(id);
|
|
1915
2129
|
const rawData = await MDB_CLIENT.db()
|
|
1916
|
-
.collection('
|
|
2130
|
+
.collection('models')
|
|
1917
2131
|
.findOne({_id: oid});
|
|
1918
2132
|
expect(rawData).to.be.eql({_id: oid, bar: 20});
|
|
1919
2133
|
});
|
|
@@ -1929,7 +2143,7 @@ describe('MongodbAdapter', function () {
|
|
|
1929
2143
|
});
|
|
1930
2144
|
expect(replaced).to.be.eql({[DEF_PK]: 'foo', prop: 20});
|
|
1931
2145
|
const rawData = await MDB_CLIENT.db()
|
|
1932
|
-
.collection('
|
|
2146
|
+
.collection('models')
|
|
1933
2147
|
.findOne({_id: 'foo'});
|
|
1934
2148
|
expect(rawData).to.be.eql({_id: 'foo', prop: 20});
|
|
1935
2149
|
});
|
|
@@ -1952,7 +2166,7 @@ describe('MongodbAdapter', function () {
|
|
|
1952
2166
|
const replaced = await rep.replaceById('foo', {myId: 'bar', prop: 20});
|
|
1953
2167
|
expect(replaced).to.be.eql({myId: 'foo', prop: 20});
|
|
1954
2168
|
const rawData = await MDB_CLIENT.db()
|
|
1955
|
-
.collection('
|
|
2169
|
+
.collection('models')
|
|
1956
2170
|
.findOne({_id: 'foo'});
|
|
1957
2171
|
expect(rawData).to.be.eql({_id: 'foo', prop: 20});
|
|
1958
2172
|
});
|
|
@@ -2007,7 +2221,7 @@ describe('MongodbAdapter', function () {
|
|
|
2007
2221
|
expect(replaced).to.be.eql({[DEF_PK]: id, foo: 20});
|
|
2008
2222
|
const oid = new ObjectId(id);
|
|
2009
2223
|
const rawData = await MDB_CLIENT.db()
|
|
2010
|
-
.collection('
|
|
2224
|
+
.collection('models')
|
|
2011
2225
|
.findOne({_id: oid});
|
|
2012
2226
|
expect(rawData).to.be.eql({_id: oid, bar: 20});
|
|
2013
2227
|
});
|
|
@@ -2024,7 +2238,7 @@ describe('MongodbAdapter', function () {
|
|
|
2024
2238
|
expect(replaced).to.be.eql({[DEF_PK]: id, date: dateString});
|
|
2025
2239
|
const oid = new ObjectId(id);
|
|
2026
2240
|
const rawData = await MDB_CLIENT.db()
|
|
2027
|
-
.collection('
|
|
2241
|
+
.collection('models')
|
|
2028
2242
|
.findOne({_id: oid});
|
|
2029
2243
|
expect(rawData).to.be.eql({_id: oid, date});
|
|
2030
2244
|
});
|
|
@@ -2041,7 +2255,7 @@ describe('MongodbAdapter', function () {
|
|
|
2041
2255
|
expect(replaced).to.be.eql({[DEF_PK]: id, date: dateString});
|
|
2042
2256
|
const oid = new ObjectId(id);
|
|
2043
2257
|
const rawData = await MDB_CLIENT.db()
|
|
2044
|
-
.collection('
|
|
2258
|
+
.collection('models')
|
|
2045
2259
|
.findOne({_id: oid});
|
|
2046
2260
|
expect(rawData).to.be.eql({_id: oid, date});
|
|
2047
2261
|
});
|
|
@@ -2056,7 +2270,7 @@ describe('MongodbAdapter', function () {
|
|
|
2056
2270
|
expect(replaced).to.be.eql({[DEF_PK]: id, foo: 'str'});
|
|
2057
2271
|
const oid = new ObjectId(id);
|
|
2058
2272
|
const rawData = await MDB_CLIENT.db()
|
|
2059
|
-
.collection('
|
|
2273
|
+
.collection('models')
|
|
2060
2274
|
.findOne({_id: oid});
|
|
2061
2275
|
expect(rawData).to.be.eql({_id: oid, foo: 'str'});
|
|
2062
2276
|
});
|
|
@@ -2071,7 +2285,7 @@ describe('MongodbAdapter', function () {
|
|
|
2071
2285
|
expect(replaced).to.be.eql({[DEF_PK]: id, foo: 10});
|
|
2072
2286
|
const oid = new ObjectId(id);
|
|
2073
2287
|
const rawData = await MDB_CLIENT.db()
|
|
2074
|
-
.collection('
|
|
2288
|
+
.collection('models')
|
|
2075
2289
|
.findOne({_id: oid});
|
|
2076
2290
|
expect(rawData).to.be.eql({_id: oid, foo: 10});
|
|
2077
2291
|
});
|
|
@@ -2086,7 +2300,7 @@ describe('MongodbAdapter', function () {
|
|
|
2086
2300
|
expect(replaced).to.be.eql({[DEF_PK]: id, foo: true, bar: false});
|
|
2087
2301
|
const oid = new ObjectId(id);
|
|
2088
2302
|
const rawData = await MDB_CLIENT.db()
|
|
2089
|
-
.collection('
|
|
2303
|
+
.collection('models')
|
|
2090
2304
|
.findOne({_id: oid});
|
|
2091
2305
|
expect(rawData).to.be.eql({_id: oid, foo: true, bar: false});
|
|
2092
2306
|
});
|
|
@@ -2101,7 +2315,7 @@ describe('MongodbAdapter', function () {
|
|
|
2101
2315
|
expect(replaced).to.be.eql({[DEF_PK]: id, foo: ['bar']});
|
|
2102
2316
|
const oid = new ObjectId(id);
|
|
2103
2317
|
const rawData = await MDB_CLIENT.db()
|
|
2104
|
-
.collection('
|
|
2318
|
+
.collection('models')
|
|
2105
2319
|
.findOne({_id: oid});
|
|
2106
2320
|
expect(rawData).to.be.eql({_id: oid, foo: ['bar']});
|
|
2107
2321
|
});
|
|
@@ -2116,7 +2330,7 @@ describe('MongodbAdapter', function () {
|
|
|
2116
2330
|
expect(replaced).to.be.eql({[DEF_PK]: id, foo: {bar: 10}});
|
|
2117
2331
|
const oid = new ObjectId(id);
|
|
2118
2332
|
const rawData = await MDB_CLIENT.db()
|
|
2119
|
-
.collection('
|
|
2333
|
+
.collection('models')
|
|
2120
2334
|
.findOne({_id: oid});
|
|
2121
2335
|
expect(rawData).to.be.eql({_id: oid, foo: {bar: 10}});
|
|
2122
2336
|
});
|
|
@@ -2131,7 +2345,7 @@ describe('MongodbAdapter', function () {
|
|
|
2131
2345
|
expect(replaced).to.be.eql({[DEF_PK]: id, foo: null});
|
|
2132
2346
|
const oid = new ObjectId(id);
|
|
2133
2347
|
const rawData = await MDB_CLIENT.db()
|
|
2134
|
-
.collection('
|
|
2348
|
+
.collection('models')
|
|
2135
2349
|
.findOne({_id: oid});
|
|
2136
2350
|
expect(rawData).to.be.eql({_id: oid, foo: null});
|
|
2137
2351
|
});
|
|
@@ -2146,7 +2360,7 @@ describe('MongodbAdapter', function () {
|
|
|
2146
2360
|
expect(replaced).to.be.eql({[DEF_PK]: id, foo: null});
|
|
2147
2361
|
const oid = new ObjectId(id);
|
|
2148
2362
|
const rawData = await MDB_CLIENT.db()
|
|
2149
|
-
.collection('
|
|
2363
|
+
.collection('models')
|
|
2150
2364
|
.findOne({_id: oid});
|
|
2151
2365
|
expect(rawData).to.be.eql({_id: oid, foo: null});
|
|
2152
2366
|
});
|
|
@@ -2165,7 +2379,7 @@ describe('MongodbAdapter', function () {
|
|
|
2165
2379
|
expect(replaced).to.be.eql({[DEF_PK]: id, foo: 15});
|
|
2166
2380
|
const oid = new ObjectId(id);
|
|
2167
2381
|
const rawData = await MDB_CLIENT.db()
|
|
2168
|
-
.collection('
|
|
2382
|
+
.collection('models')
|
|
2169
2383
|
.findOne({_id: oid});
|
|
2170
2384
|
expect(rawData).to.be.eql({_id: oid, foo: 15, bar: 25});
|
|
2171
2385
|
});
|
|
@@ -2184,7 +2398,7 @@ describe('MongodbAdapter', function () {
|
|
|
2184
2398
|
expect(replaced).to.be.eql({[DEF_PK]: id, foo: 15, bar: 25});
|
|
2185
2399
|
const oid = new ObjectId(id);
|
|
2186
2400
|
const rawData = await MDB_CLIENT.db()
|
|
2187
|
-
.collection('
|
|
2401
|
+
.collection('models')
|
|
2188
2402
|
.findOne({_id: oid});
|
|
2189
2403
|
expect(rawData).to.be.eql({_id: oid, foo: 15, bar: 25, baz: 35});
|
|
2190
2404
|
});
|
|
@@ -2223,7 +2437,7 @@ describe('MongodbAdapter', function () {
|
|
|
2223
2437
|
expect(replaced).to.be.eql({[DEF_PK]: replaced[DEF_PK]});
|
|
2224
2438
|
const oid = new ObjectId(id);
|
|
2225
2439
|
const rawData = await MDB_CLIENT.db()
|
|
2226
|
-
.collection('
|
|
2440
|
+
.collection('models')
|
|
2227
2441
|
.findOne({_id: oid});
|
|
2228
2442
|
expect(rawData).to.be.eql({_id: oid, fooCol: 15, barCol: 25, bazCol: 35});
|
|
2229
2443
|
});
|
|
@@ -2238,7 +2452,7 @@ describe('MongodbAdapter', function () {
|
|
|
2238
2452
|
expect(replaced).to.be.eql({[DEF_PK]: id, foo: 10});
|
|
2239
2453
|
const oid = new ObjectId(id);
|
|
2240
2454
|
const rawData = await MDB_CLIENT.db()
|
|
2241
|
-
.collection('
|
|
2455
|
+
.collection('models')
|
|
2242
2456
|
.findOne({_id: oid});
|
|
2243
2457
|
expect(rawData).to.be.eql({_id: oid, foo: 10});
|
|
2244
2458
|
});
|
|
@@ -2428,7 +2642,7 @@ describe('MongodbAdapter', function () {
|
|
|
2428
2642
|
const result = await rep.replaceOrCreate({[DEF_PK]: oid});
|
|
2429
2643
|
expect(result).to.be.eql({[DEF_PK]: String(oid)});
|
|
2430
2644
|
const rawData = await MDB_CLIENT.db()
|
|
2431
|
-
.collection('
|
|
2645
|
+
.collection('models')
|
|
2432
2646
|
.findOne({_id: oid});
|
|
2433
2647
|
expect(rawData).to.be.not.null;
|
|
2434
2648
|
});
|
|
@@ -2442,7 +2656,7 @@ describe('MongodbAdapter', function () {
|
|
|
2442
2656
|
const result = await rep.replaceOrCreate({[DEF_PK]: id});
|
|
2443
2657
|
expect(result).to.be.eql({[DEF_PK]: id});
|
|
2444
2658
|
const rawData = await MDB_CLIENT.db()
|
|
2445
|
-
.collection('
|
|
2659
|
+
.collection('models')
|
|
2446
2660
|
.findOne({_id: oid});
|
|
2447
2661
|
expect(rawData).to.be.not.null;
|
|
2448
2662
|
});
|
|
@@ -2464,7 +2678,7 @@ describe('MongodbAdapter', function () {
|
|
|
2464
2678
|
const result = await rep.replaceOrCreate({id: oid});
|
|
2465
2679
|
expect(result).to.be.eql({id: String(oid)});
|
|
2466
2680
|
const rawData = await MDB_CLIENT.db()
|
|
2467
|
-
.collection('
|
|
2681
|
+
.collection('models')
|
|
2468
2682
|
.findOne({_id: oid});
|
|
2469
2683
|
expect(rawData).to.be.not.null;
|
|
2470
2684
|
});
|
|
@@ -2487,7 +2701,7 @@ describe('MongodbAdapter', function () {
|
|
|
2487
2701
|
const result = await rep.replaceOrCreate({id});
|
|
2488
2702
|
expect(result).to.be.eql({id});
|
|
2489
2703
|
const rawData = await MDB_CLIENT.db()
|
|
2490
|
-
.collection('
|
|
2704
|
+
.collection('models')
|
|
2491
2705
|
.findOne({_id: oid});
|
|
2492
2706
|
expect(rawData).to.be.not.null;
|
|
2493
2707
|
});
|
|
@@ -2509,7 +2723,7 @@ describe('MongodbAdapter', function () {
|
|
|
2509
2723
|
const result = await rep.replaceOrCreate({_id: oid});
|
|
2510
2724
|
expect(result).to.be.eql({_id: String(oid)});
|
|
2511
2725
|
const rawData = await MDB_CLIENT.db()
|
|
2512
|
-
.collection('
|
|
2726
|
+
.collection('models')
|
|
2513
2727
|
.findOne({_id: oid});
|
|
2514
2728
|
expect(rawData).to.be.not.null;
|
|
2515
2729
|
});
|
|
@@ -2532,7 +2746,7 @@ describe('MongodbAdapter', function () {
|
|
|
2532
2746
|
const result = await rep.replaceOrCreate({_id: id});
|
|
2533
2747
|
expect(result).to.be.eql({_id: id});
|
|
2534
2748
|
const rawData = await MDB_CLIENT.db()
|
|
2535
|
-
.collection('
|
|
2749
|
+
.collection('models')
|
|
2536
2750
|
.findOne({_id: oid});
|
|
2537
2751
|
expect(rawData).to.be.not.null;
|
|
2538
2752
|
});
|
|
@@ -2575,7 +2789,7 @@ describe('MongodbAdapter', function () {
|
|
|
2575
2789
|
expect(result).to.be.eql({[DEF_PK]: result[DEF_PK], foo: 10});
|
|
2576
2790
|
const oid = new ObjectId(result[DEF_PK]);
|
|
2577
2791
|
const rawData = await MDB_CLIENT.db()
|
|
2578
|
-
.collection('
|
|
2792
|
+
.collection('models')
|
|
2579
2793
|
.findOne({_id: oid});
|
|
2580
2794
|
expect(rawData).to.be.eql({_id: oid, bar: 10});
|
|
2581
2795
|
});
|
|
@@ -2598,7 +2812,7 @@ describe('MongodbAdapter', function () {
|
|
|
2598
2812
|
expect(result).to.be.eql({[DEF_PK]: result[DEF_PK], foo: 10});
|
|
2599
2813
|
const oid = new ObjectId(result[DEF_PK]);
|
|
2600
2814
|
const rawData = await MDB_CLIENT.db()
|
|
2601
|
-
.collection('
|
|
2815
|
+
.collection('models')
|
|
2602
2816
|
.findOne({_id: oid});
|
|
2603
2817
|
expect(rawData).to.be.eql({_id: oid, bar: 10});
|
|
2604
2818
|
});
|
|
@@ -2613,7 +2827,7 @@ describe('MongodbAdapter', function () {
|
|
|
2613
2827
|
expect(result).to.be.eql({[DEF_PK]: result[DEF_PK], date: dateString});
|
|
2614
2828
|
const oid = new ObjectId(result[DEF_PK]);
|
|
2615
2829
|
const rawData = await MDB_CLIENT.db()
|
|
2616
|
-
.collection('
|
|
2830
|
+
.collection('models')
|
|
2617
2831
|
.findOne({_id: oid});
|
|
2618
2832
|
expect(rawData).to.be.eql({_id: oid, date});
|
|
2619
2833
|
});
|
|
@@ -2628,7 +2842,7 @@ describe('MongodbAdapter', function () {
|
|
|
2628
2842
|
expect(result).to.be.eql({[DEF_PK]: result[DEF_PK], date: dateString});
|
|
2629
2843
|
const oid = new ObjectId(result[DEF_PK]);
|
|
2630
2844
|
const rawData = await MDB_CLIENT.db()
|
|
2631
|
-
.collection('
|
|
2845
|
+
.collection('models')
|
|
2632
2846
|
.findOne({_id: oid});
|
|
2633
2847
|
expect(rawData).to.be.eql({_id: oid, date});
|
|
2634
2848
|
});
|
|
@@ -2641,7 +2855,7 @@ describe('MongodbAdapter', function () {
|
|
|
2641
2855
|
expect(result).to.be.eql({[DEF_PK]: result[DEF_PK], foo: 'str'});
|
|
2642
2856
|
const oid = new ObjectId(result[DEF_PK]);
|
|
2643
2857
|
const rawData = await MDB_CLIENT.db()
|
|
2644
|
-
.collection('
|
|
2858
|
+
.collection('models')
|
|
2645
2859
|
.findOne({_id: oid});
|
|
2646
2860
|
expect(rawData).to.be.eql({_id: oid, foo: 'str'});
|
|
2647
2861
|
});
|
|
@@ -2654,7 +2868,7 @@ describe('MongodbAdapter', function () {
|
|
|
2654
2868
|
expect(result).to.be.eql({[DEF_PK]: result[DEF_PK], foo: 10});
|
|
2655
2869
|
const oid = new ObjectId(result[DEF_PK]);
|
|
2656
2870
|
const rawData = await MDB_CLIENT.db()
|
|
2657
|
-
.collection('
|
|
2871
|
+
.collection('models')
|
|
2658
2872
|
.findOne({_id: oid});
|
|
2659
2873
|
expect(rawData).to.be.eql({_id: oid, foo: 10});
|
|
2660
2874
|
});
|
|
@@ -2671,7 +2885,7 @@ describe('MongodbAdapter', function () {
|
|
|
2671
2885
|
});
|
|
2672
2886
|
const oid = new ObjectId(result[DEF_PK]);
|
|
2673
2887
|
const rawData = await MDB_CLIENT.db()
|
|
2674
|
-
.collection('
|
|
2888
|
+
.collection('models')
|
|
2675
2889
|
.findOne({_id: oid});
|
|
2676
2890
|
expect(rawData).to.be.eql({_id: oid, foo: true, bar: false});
|
|
2677
2891
|
});
|
|
@@ -2687,7 +2901,7 @@ describe('MongodbAdapter', function () {
|
|
|
2687
2901
|
});
|
|
2688
2902
|
const oid = new ObjectId(result[DEF_PK]);
|
|
2689
2903
|
const rawData = await MDB_CLIENT.db()
|
|
2690
|
-
.collection('
|
|
2904
|
+
.collection('models')
|
|
2691
2905
|
.findOne({_id: oid});
|
|
2692
2906
|
expect(rawData).to.be.eql({_id: oid, foo: ['bar']});
|
|
2693
2907
|
});
|
|
@@ -2703,7 +2917,7 @@ describe('MongodbAdapter', function () {
|
|
|
2703
2917
|
});
|
|
2704
2918
|
const oid = new ObjectId(result[DEF_PK]);
|
|
2705
2919
|
const rawData = await MDB_CLIENT.db()
|
|
2706
|
-
.collection('
|
|
2920
|
+
.collection('models')
|
|
2707
2921
|
.findOne({_id: oid});
|
|
2708
2922
|
expect(rawData).to.be.eql({_id: oid, foo: {bar: 10}});
|
|
2709
2923
|
});
|
|
@@ -2719,7 +2933,7 @@ describe('MongodbAdapter', function () {
|
|
|
2719
2933
|
});
|
|
2720
2934
|
const oid = new ObjectId(result[DEF_PK]);
|
|
2721
2935
|
const rawData = await MDB_CLIENT.db()
|
|
2722
|
-
.collection('
|
|
2936
|
+
.collection('models')
|
|
2723
2937
|
.findOne({_id: oid});
|
|
2724
2938
|
expect(rawData).to.be.eql({_id: oid, foo: null});
|
|
2725
2939
|
});
|
|
@@ -2735,7 +2949,7 @@ describe('MongodbAdapter', function () {
|
|
|
2735
2949
|
});
|
|
2736
2950
|
const oid = new ObjectId(result[DEF_PK]);
|
|
2737
2951
|
const rawData = await MDB_CLIENT.db()
|
|
2738
|
-
.collection('
|
|
2952
|
+
.collection('models')
|
|
2739
2953
|
.findOne({_id: oid});
|
|
2740
2954
|
expect(rawData).to.be.eql({_id: oid, foo: null});
|
|
2741
2955
|
});
|
|
@@ -2762,7 +2976,7 @@ describe('MongodbAdapter', function () {
|
|
|
2762
2976
|
expect(result).to.be.eql({[DEF_PK]: result[DEF_PK], foo: 10, bar: 20});
|
|
2763
2977
|
const oid = new ObjectId(result[DEF_PK]);
|
|
2764
2978
|
const rawData = await MDB_CLIENT.db()
|
|
2765
|
-
.collection('
|
|
2979
|
+
.collection('models')
|
|
2766
2980
|
.findOne({_id: oid});
|
|
2767
2981
|
expect(rawData).to.be.eql({_id: oid, foo: 10, bar: 20, baz: 30});
|
|
2768
2982
|
});
|
|
@@ -2806,7 +3020,7 @@ describe('MongodbAdapter', function () {
|
|
|
2806
3020
|
expect(replaced).to.be.eql(replacer);
|
|
2807
3021
|
const oid = new ObjectId(id);
|
|
2808
3022
|
const rawData = await MDB_CLIENT.db()
|
|
2809
|
-
.collection('
|
|
3023
|
+
.collection('models')
|
|
2810
3024
|
.findOne({_id: oid});
|
|
2811
3025
|
expect(rawData).to.be.eql({_id: oid, bar: 20});
|
|
2812
3026
|
});
|
|
@@ -2822,7 +3036,7 @@ describe('MongodbAdapter', function () {
|
|
|
2822
3036
|
expect(replaced).to.be.eql(replacer);
|
|
2823
3037
|
const oid = new ObjectId(id);
|
|
2824
3038
|
const rawData = await MDB_CLIENT.db()
|
|
2825
|
-
.collection('
|
|
3039
|
+
.collection('models')
|
|
2826
3040
|
.findOne({_id: oid});
|
|
2827
3041
|
expect(rawData).to.be.eql({_id: oid, foo: 10});
|
|
2828
3042
|
});
|
|
@@ -2852,7 +3066,7 @@ describe('MongodbAdapter', function () {
|
|
|
2852
3066
|
const result = await rep.patch({foo: 'd1'});
|
|
2853
3067
|
expect(result).to.be.eq(3);
|
|
2854
3068
|
const rawData = await MDB_CLIENT.db()
|
|
2855
|
-
.collection('
|
|
3069
|
+
.collection('models')
|
|
2856
3070
|
.find()
|
|
2857
3071
|
.toArray();
|
|
2858
3072
|
expect(rawData).to.be.eql([
|
|
@@ -2888,7 +3102,7 @@ describe('MongodbAdapter', function () {
|
|
|
2888
3102
|
const result = await rep.patch({foo: 'd1'});
|
|
2889
3103
|
expect(result).to.be.eq(3);
|
|
2890
3104
|
const rawData = await MDB_CLIENT.db()
|
|
2891
|
-
.collection('
|
|
3105
|
+
.collection('models')
|
|
2892
3106
|
.find()
|
|
2893
3107
|
.toArray();
|
|
2894
3108
|
expect(rawData).to.be.eql([
|
|
@@ -2921,7 +3135,7 @@ describe('MongodbAdapter', function () {
|
|
|
2921
3135
|
const result = await rep.patch({[DEF_PK]: '100', foo: 'd1'});
|
|
2922
3136
|
expect(result).to.be.eq(3);
|
|
2923
3137
|
const rawData = await MDB_CLIENT.db()
|
|
2924
|
-
.collection('
|
|
3138
|
+
.collection('models')
|
|
2925
3139
|
.find()
|
|
2926
3140
|
.toArray();
|
|
2927
3141
|
expect(rawData).to.be.eql([
|
|
@@ -2958,7 +3172,7 @@ describe('MongodbAdapter', function () {
|
|
|
2958
3172
|
const result = await rep.patch({id: '100', foo: 'd1'});
|
|
2959
3173
|
expect(result).to.be.eq(3);
|
|
2960
3174
|
const rawData = await MDB_CLIENT.db()
|
|
2961
|
-
.collection('
|
|
3175
|
+
.collection('models')
|
|
2962
3176
|
.find()
|
|
2963
3177
|
.toArray();
|
|
2964
3178
|
expect(rawData).to.be.eql([
|
|
@@ -2997,7 +3211,7 @@ describe('MongodbAdapter', function () {
|
|
|
2997
3211
|
const result = await rep.patch({foo: undefined});
|
|
2998
3212
|
expect(result).to.be.eq(3);
|
|
2999
3213
|
const rawData = await MDB_CLIENT.db()
|
|
3000
|
-
.collection('
|
|
3214
|
+
.collection('models')
|
|
3001
3215
|
.find()
|
|
3002
3216
|
.toArray();
|
|
3003
3217
|
expect(rawData).to.be.eql([
|
|
@@ -3036,7 +3250,7 @@ describe('MongodbAdapter', function () {
|
|
|
3036
3250
|
const result = await rep.patch({foo: null});
|
|
3037
3251
|
expect(result).to.be.eq(3);
|
|
3038
3252
|
const rawData = await MDB_CLIENT.db()
|
|
3039
|
-
.collection('
|
|
3253
|
+
.collection('models')
|
|
3040
3254
|
.find()
|
|
3041
3255
|
.toArray();
|
|
3042
3256
|
expect(rawData).to.be.eql([
|
|
@@ -3075,7 +3289,7 @@ describe('MongodbAdapter', function () {
|
|
|
3075
3289
|
const result = await rep.patch({foo: 'd1'});
|
|
3076
3290
|
expect(result).to.be.eq(3);
|
|
3077
3291
|
const rawData = await MDB_CLIENT.db()
|
|
3078
|
-
.collection('
|
|
3292
|
+
.collection('models')
|
|
3079
3293
|
.find()
|
|
3080
3294
|
.toArray();
|
|
3081
3295
|
expect(rawData).to.be.eql([
|
|
@@ -3116,7 +3330,7 @@ describe('MongodbAdapter', function () {
|
|
|
3116
3330
|
const result = await rep.patch({foo: undefined});
|
|
3117
3331
|
expect(result).to.be.eq(3);
|
|
3118
3332
|
const rawData = await MDB_CLIENT.db()
|
|
3119
|
-
.collection('
|
|
3333
|
+
.collection('models')
|
|
3120
3334
|
.find()
|
|
3121
3335
|
.toArray();
|
|
3122
3336
|
expect(rawData).to.be.eql([
|
|
@@ -3149,7 +3363,7 @@ describe('MongodbAdapter', function () {
|
|
|
3149
3363
|
const result = await rep.patch({foo: 'test'}, {baz: 'd3'});
|
|
3150
3364
|
expect(result).to.be.eq(0);
|
|
3151
3365
|
const rawData = await MDB_CLIENT.db()
|
|
3152
|
-
.collection('
|
|
3366
|
+
.collection('models')
|
|
3153
3367
|
.find()
|
|
3154
3368
|
.toArray();
|
|
3155
3369
|
expect(rawData).to.be.eql([
|
|
@@ -3182,7 +3396,7 @@ describe('MongodbAdapter', function () {
|
|
|
3182
3396
|
const result = await rep.patch({foo: 'd'}, {bar: '2'});
|
|
3183
3397
|
expect(result).to.be.eq(2);
|
|
3184
3398
|
const rawData = await MDB_CLIENT.db()
|
|
3185
|
-
.collection('
|
|
3399
|
+
.collection('models')
|
|
3186
3400
|
.find()
|
|
3187
3401
|
.toArray();
|
|
3188
3402
|
expect(rawData).to.be.eql([
|
|
@@ -3221,7 +3435,7 @@ describe('MongodbAdapter', function () {
|
|
|
3221
3435
|
const result = await rep.patch({foo: 'd'}, {bar: '2'});
|
|
3222
3436
|
expect(result).to.be.eq(2);
|
|
3223
3437
|
const rawData = await MDB_CLIENT.db()
|
|
3224
|
-
.collection('
|
|
3438
|
+
.collection('models')
|
|
3225
3439
|
.find()
|
|
3226
3440
|
.toArray();
|
|
3227
3441
|
expect(rawData).to.be.eql([
|
|
@@ -3249,7 +3463,7 @@ describe('MongodbAdapter', function () {
|
|
|
3249
3463
|
const input2 = {foo: 'b', bar: undefined};
|
|
3250
3464
|
const input3 = {foo: 'c', bar: 10};
|
|
3251
3465
|
const input4 = {foo: 'd', bar: null};
|
|
3252
|
-
const table = await MDB_CLIENT.db().collection('
|
|
3466
|
+
const table = await MDB_CLIENT.db().collection('models');
|
|
3253
3467
|
const {insertedIds} = await table.insertMany([
|
|
3254
3468
|
input1,
|
|
3255
3469
|
input2,
|
|
@@ -3285,7 +3499,7 @@ describe('MongodbAdapter', function () {
|
|
|
3285
3499
|
const input2 = {foo: 'b', bar: undefined};
|
|
3286
3500
|
const input3 = {foo: 'c', bar: 10};
|
|
3287
3501
|
const input4 = {foo: 'd', bar: null};
|
|
3288
|
-
const table = await MDB_CLIENT.db().collection('
|
|
3502
|
+
const table = await MDB_CLIENT.db().collection('models');
|
|
3289
3503
|
const {insertedIds} = await table.insertMany([
|
|
3290
3504
|
input1,
|
|
3291
3505
|
input2,
|
|
@@ -3317,7 +3531,7 @@ describe('MongodbAdapter', function () {
|
|
|
3317
3531
|
const result = await rep.patch({foo: 7}, {foo: 10});
|
|
3318
3532
|
expect(result).to.be.eq(1);
|
|
3319
3533
|
const rawData = await MDB_CLIENT.db()
|
|
3320
|
-
.collection('
|
|
3534
|
+
.collection('models')
|
|
3321
3535
|
.find()
|
|
3322
3536
|
.toArray();
|
|
3323
3537
|
expect(rawData).to.be.eql([
|
|
@@ -3340,7 +3554,7 @@ describe('MongodbAdapter', function () {
|
|
|
3340
3554
|
const result = await rep.patch({foo: 7}, {foo: {eq: 10}});
|
|
3341
3555
|
expect(result).to.be.eq(1);
|
|
3342
3556
|
const rawData = await MDB_CLIENT.db()
|
|
3343
|
-
.collection('
|
|
3557
|
+
.collection('models')
|
|
3344
3558
|
.find()
|
|
3345
3559
|
.toArray();
|
|
3346
3560
|
expect(rawData).to.be.eql([
|
|
@@ -3363,7 +3577,7 @@ describe('MongodbAdapter', function () {
|
|
|
3363
3577
|
const result = await rep.patch({foo: 7}, {foo: {neq: 10}});
|
|
3364
3578
|
expect(result).to.be.eq(2);
|
|
3365
3579
|
const rawData = await MDB_CLIENT.db()
|
|
3366
|
-
.collection('
|
|
3580
|
+
.collection('models')
|
|
3367
3581
|
.find()
|
|
3368
3582
|
.toArray();
|
|
3369
3583
|
expect(rawData).to.be.eql([
|
|
@@ -3386,7 +3600,7 @@ describe('MongodbAdapter', function () {
|
|
|
3386
3600
|
const result = await rep.patch({foo: 7}, {foo: {gt: 10}});
|
|
3387
3601
|
expect(result).to.be.eq(1);
|
|
3388
3602
|
const rawData = await MDB_CLIENT.db()
|
|
3389
|
-
.collection('
|
|
3603
|
+
.collection('models')
|
|
3390
3604
|
.find()
|
|
3391
3605
|
.toArray();
|
|
3392
3606
|
expect(rawData).to.be.eql([
|
|
@@ -3409,7 +3623,7 @@ describe('MongodbAdapter', function () {
|
|
|
3409
3623
|
const result = await rep.patch({foo: 7}, {foo: {lt: 10}});
|
|
3410
3624
|
expect(result).to.be.eq(1);
|
|
3411
3625
|
const rawData = await MDB_CLIENT.db()
|
|
3412
|
-
.collection('
|
|
3626
|
+
.collection('models')
|
|
3413
3627
|
.find()
|
|
3414
3628
|
.toArray();
|
|
3415
3629
|
expect(rawData).to.be.eql([
|
|
@@ -3432,7 +3646,7 @@ describe('MongodbAdapter', function () {
|
|
|
3432
3646
|
const result = await rep.patch({foo: 7}, {foo: {gte: 10}});
|
|
3433
3647
|
expect(result).to.be.eq(2);
|
|
3434
3648
|
const rawData = await MDB_CLIENT.db()
|
|
3435
|
-
.collection('
|
|
3649
|
+
.collection('models')
|
|
3436
3650
|
.find()
|
|
3437
3651
|
.toArray();
|
|
3438
3652
|
expect(rawData).to.be.eql([
|
|
@@ -3455,7 +3669,7 @@ describe('MongodbAdapter', function () {
|
|
|
3455
3669
|
const result = await rep.patch({foo: 7}, {foo: {lte: 10}});
|
|
3456
3670
|
expect(result).to.be.eq(2);
|
|
3457
3671
|
const rawData = await MDB_CLIENT.db()
|
|
3458
|
-
.collection('
|
|
3672
|
+
.collection('models')
|
|
3459
3673
|
.find()
|
|
3460
3674
|
.toArray();
|
|
3461
3675
|
expect(rawData).to.be.eql([
|
|
@@ -3478,7 +3692,7 @@ describe('MongodbAdapter', function () {
|
|
|
3478
3692
|
const result = await rep.patch({foo: 7}, {foo: {inq: [5, 10]}});
|
|
3479
3693
|
expect(result).to.be.eq(2);
|
|
3480
3694
|
const rawData = await MDB_CLIENT.db()
|
|
3481
|
-
.collection('
|
|
3695
|
+
.collection('models')
|
|
3482
3696
|
.find()
|
|
3483
3697
|
.toArray();
|
|
3484
3698
|
expect(rawData).to.be.eql([
|
|
@@ -3501,7 +3715,7 @@ describe('MongodbAdapter', function () {
|
|
|
3501
3715
|
const result = await rep.patch({foo: 7}, {foo: {nin: [5, 10]}});
|
|
3502
3716
|
expect(result).to.be.eq(1);
|
|
3503
3717
|
const rawData = await MDB_CLIENT.db()
|
|
3504
|
-
.collection('
|
|
3718
|
+
.collection('models')
|
|
3505
3719
|
.find()
|
|
3506
3720
|
.toArray();
|
|
3507
3721
|
expect(rawData).to.be.eql([
|
|
@@ -3524,7 +3738,7 @@ describe('MongodbAdapter', function () {
|
|
|
3524
3738
|
const result = await rep.patch({foo: 7}, {foo: {between: [5, 10]}});
|
|
3525
3739
|
expect(result).to.be.eq(2);
|
|
3526
3740
|
const rawData = await MDB_CLIENT.db()
|
|
3527
|
-
.collection('
|
|
3741
|
+
.collection('models')
|
|
3528
3742
|
.find()
|
|
3529
3743
|
.toArray();
|
|
3530
3744
|
expect(rawData).to.be.eql([
|
|
@@ -3549,7 +3763,7 @@ describe('MongodbAdapter', function () {
|
|
|
3549
3763
|
const result = await rep.patch({foo: 7}, {foo: {exists: true}});
|
|
3550
3764
|
expect(result).to.be.eq(3);
|
|
3551
3765
|
const rawData = await MDB_CLIENT.db()
|
|
3552
|
-
.collection('
|
|
3766
|
+
.collection('models')
|
|
3553
3767
|
.find()
|
|
3554
3768
|
.toArray();
|
|
3555
3769
|
expect(rawData).to.be.eql([
|
|
@@ -3575,7 +3789,7 @@ describe('MongodbAdapter', function () {
|
|
|
3575
3789
|
const result = await rep.patch({foo: 7}, {foo: {exists: false}});
|
|
3576
3790
|
expect(result).to.be.eq(1);
|
|
3577
3791
|
const rawData = await MDB_CLIENT.db()
|
|
3578
|
-
.collection('
|
|
3792
|
+
.collection('models')
|
|
3579
3793
|
.find()
|
|
3580
3794
|
.toArray();
|
|
3581
3795
|
expect(rawData).to.be.eql([
|
|
@@ -3604,7 +3818,7 @@ describe('MongodbAdapter', function () {
|
|
|
3604
3818
|
);
|
|
3605
3819
|
expect(result).to.be.eq(2);
|
|
3606
3820
|
const rawData = await MDB_CLIENT.db()
|
|
3607
|
-
.collection('
|
|
3821
|
+
.collection('models')
|
|
3608
3822
|
.find()
|
|
3609
3823
|
.toArray();
|
|
3610
3824
|
expect(rawData).to.be.eql([
|
|
@@ -3633,7 +3847,7 @@ describe('MongodbAdapter', function () {
|
|
|
3633
3847
|
);
|
|
3634
3848
|
expect(result).to.be.eq(2);
|
|
3635
3849
|
const rawData = await MDB_CLIENT.db()
|
|
3636
|
-
.collection('
|
|
3850
|
+
.collection('models')
|
|
3637
3851
|
.find()
|
|
3638
3852
|
.toArray();
|
|
3639
3853
|
expect(rawData).to.be.eql([
|
|
@@ -3662,7 +3876,7 @@ describe('MongodbAdapter', function () {
|
|
|
3662
3876
|
);
|
|
3663
3877
|
expect(result).to.be.eq(3);
|
|
3664
3878
|
const rawData = await MDB_CLIENT.db()
|
|
3665
|
-
.collection('
|
|
3879
|
+
.collection('models')
|
|
3666
3880
|
.find()
|
|
3667
3881
|
.toArray();
|
|
3668
3882
|
expect(rawData).to.be.eql([
|
|
@@ -3691,7 +3905,7 @@ describe('MongodbAdapter', function () {
|
|
|
3691
3905
|
);
|
|
3692
3906
|
expect(result).to.be.eq(1);
|
|
3693
3907
|
const rawData = await MDB_CLIENT.db()
|
|
3694
|
-
.collection('
|
|
3908
|
+
.collection('models')
|
|
3695
3909
|
.find()
|
|
3696
3910
|
.toArray();
|
|
3697
3911
|
expect(rawData).to.be.eql([
|
|
@@ -3720,7 +3934,7 @@ describe('MongodbAdapter', function () {
|
|
|
3720
3934
|
);
|
|
3721
3935
|
expect(result).to.be.eq(2);
|
|
3722
3936
|
const rawData = await MDB_CLIENT.db()
|
|
3723
|
-
.collection('
|
|
3937
|
+
.collection('models')
|
|
3724
3938
|
.find()
|
|
3725
3939
|
.toArray();
|
|
3726
3940
|
expect(rawData).to.be.eql([
|
|
@@ -3749,7 +3963,7 @@ describe('MongodbAdapter', function () {
|
|
|
3749
3963
|
);
|
|
3750
3964
|
expect(result).to.be.eq(3);
|
|
3751
3965
|
const rawData = await MDB_CLIENT.db()
|
|
3752
|
-
.collection('
|
|
3966
|
+
.collection('models')
|
|
3753
3967
|
.find()
|
|
3754
3968
|
.toArray();
|
|
3755
3969
|
expect(rawData).to.be.eql([
|
|
@@ -3773,7 +3987,7 @@ describe('MongodbAdapter', function () {
|
|
|
3773
3987
|
expect(patched).to.be.eql({[DEF_PK]: id, foo: 10, bar: 20});
|
|
3774
3988
|
const oid = new ObjectId(id);
|
|
3775
3989
|
const rawData = await MDB_CLIENT.db()
|
|
3776
|
-
.collection('
|
|
3990
|
+
.collection('models')
|
|
3777
3991
|
.findOne({_id: oid});
|
|
3778
3992
|
expect(rawData).to.be.eql({_id: oid, foo: 10, bar: 20});
|
|
3779
3993
|
});
|
|
@@ -3792,13 +4006,13 @@ describe('MongodbAdapter', function () {
|
|
|
3792
4006
|
});
|
|
3793
4007
|
const rep = schema.getRepository('model');
|
|
3794
4008
|
const {insertedId: oid} = await MDB_CLIENT.db()
|
|
3795
|
-
.collection('
|
|
4009
|
+
.collection('models')
|
|
3796
4010
|
.insertOne({bar: 10});
|
|
3797
4011
|
const patched = await rep.patchById(oid, {baz: 20});
|
|
3798
4012
|
const id = String(oid);
|
|
3799
4013
|
expect(patched).to.be.eql({[DEF_PK]: id, bar: 10, baz: 20});
|
|
3800
4014
|
const rawData = await MDB_CLIENT.db()
|
|
3801
|
-
.collection('
|
|
4015
|
+
.collection('models')
|
|
3802
4016
|
.findOne({_id: oid});
|
|
3803
4017
|
expect(rawData).to.be.eql({_id: oid, bar: 10, baz: 20});
|
|
3804
4018
|
});
|
|
@@ -3814,7 +4028,7 @@ describe('MongodbAdapter', function () {
|
|
|
3814
4028
|
});
|
|
3815
4029
|
expect(patched).to.be.eql({[DEF_PK]: 'foo', prop: 20});
|
|
3816
4030
|
const rawData = await MDB_CLIENT.db()
|
|
3817
|
-
.collection('
|
|
4031
|
+
.collection('models')
|
|
3818
4032
|
.findOne({_id: 'foo'});
|
|
3819
4033
|
expect(rawData).to.be.eql({_id: 'foo', prop: 20});
|
|
3820
4034
|
});
|
|
@@ -3837,7 +4051,7 @@ describe('MongodbAdapter', function () {
|
|
|
3837
4051
|
const patched = await rep.patchById('foo', {myId: 'bar', prop: 20});
|
|
3838
4052
|
expect(patched).to.be.eql({myId: 'foo', prop: 20});
|
|
3839
4053
|
const rawData = await MDB_CLIENT.db()
|
|
3840
|
-
.collection('
|
|
4054
|
+
.collection('models')
|
|
3841
4055
|
.findOne({_id: 'foo'});
|
|
3842
4056
|
expect(rawData).to.be.eql({_id: 'foo', prop: 20});
|
|
3843
4057
|
});
|
|
@@ -3892,7 +4106,7 @@ describe('MongodbAdapter', function () {
|
|
|
3892
4106
|
expect(patched).to.be.eql({[DEF_PK]: id, foo: 20});
|
|
3893
4107
|
const oid = new ObjectId(id);
|
|
3894
4108
|
const rawData = await MDB_CLIENT.db()
|
|
3895
|
-
.collection('
|
|
4109
|
+
.collection('models')
|
|
3896
4110
|
.findOne({_id: oid});
|
|
3897
4111
|
expect(rawData).to.be.eql({_id: oid, bar: 20});
|
|
3898
4112
|
});
|
|
@@ -3909,7 +4123,7 @@ describe('MongodbAdapter', function () {
|
|
|
3909
4123
|
expect(patched).to.be.eql({[DEF_PK]: id, date: dateString});
|
|
3910
4124
|
const oid = new ObjectId(id);
|
|
3911
4125
|
const rawData = await MDB_CLIENT.db()
|
|
3912
|
-
.collection('
|
|
4126
|
+
.collection('models')
|
|
3913
4127
|
.findOne({_id: oid});
|
|
3914
4128
|
expect(rawData).to.be.eql({_id: oid, date});
|
|
3915
4129
|
});
|
|
@@ -3926,7 +4140,7 @@ describe('MongodbAdapter', function () {
|
|
|
3926
4140
|
expect(patched).to.be.eql({[DEF_PK]: id, date: dateString});
|
|
3927
4141
|
const oid = new ObjectId(id);
|
|
3928
4142
|
const rawData = await MDB_CLIENT.db()
|
|
3929
|
-
.collection('
|
|
4143
|
+
.collection('models')
|
|
3930
4144
|
.findOne({_id: oid});
|
|
3931
4145
|
expect(rawData).to.be.eql({_id: oid, date});
|
|
3932
4146
|
});
|
|
@@ -3941,7 +4155,7 @@ describe('MongodbAdapter', function () {
|
|
|
3941
4155
|
expect(patched).to.be.eql({[DEF_PK]: id, foo: 'str'});
|
|
3942
4156
|
const oid = new ObjectId(id);
|
|
3943
4157
|
const rawData = await MDB_CLIENT.db()
|
|
3944
|
-
.collection('
|
|
4158
|
+
.collection('models')
|
|
3945
4159
|
.findOne({_id: oid});
|
|
3946
4160
|
expect(rawData).to.be.eql({_id: oid, foo: 'str'});
|
|
3947
4161
|
});
|
|
@@ -3956,7 +4170,7 @@ describe('MongodbAdapter', function () {
|
|
|
3956
4170
|
expect(patched).to.be.eql({[DEF_PK]: id, foo: 10});
|
|
3957
4171
|
const oid = new ObjectId(id);
|
|
3958
4172
|
const rawData = await MDB_CLIENT.db()
|
|
3959
|
-
.collection('
|
|
4173
|
+
.collection('models')
|
|
3960
4174
|
.findOne({_id: oid});
|
|
3961
4175
|
expect(rawData).to.be.eql({_id: oid, foo: 10});
|
|
3962
4176
|
});
|
|
@@ -3971,7 +4185,7 @@ describe('MongodbAdapter', function () {
|
|
|
3971
4185
|
expect(patched).to.be.eql({[DEF_PK]: id, foo: true, bar: false});
|
|
3972
4186
|
const oid = new ObjectId(id);
|
|
3973
4187
|
const rawData = await MDB_CLIENT.db()
|
|
3974
|
-
.collection('
|
|
4188
|
+
.collection('models')
|
|
3975
4189
|
.findOne({_id: oid});
|
|
3976
4190
|
expect(rawData).to.be.eql({_id: oid, foo: true, bar: false});
|
|
3977
4191
|
});
|
|
@@ -3986,7 +4200,7 @@ describe('MongodbAdapter', function () {
|
|
|
3986
4200
|
expect(patched).to.be.eql({[DEF_PK]: id, foo: ['bar']});
|
|
3987
4201
|
const oid = new ObjectId(id);
|
|
3988
4202
|
const rawData = await MDB_CLIENT.db()
|
|
3989
|
-
.collection('
|
|
4203
|
+
.collection('models')
|
|
3990
4204
|
.findOne({_id: oid});
|
|
3991
4205
|
expect(rawData).to.be.eql({_id: oid, foo: ['bar']});
|
|
3992
4206
|
});
|
|
@@ -4001,7 +4215,7 @@ describe('MongodbAdapter', function () {
|
|
|
4001
4215
|
expect(patched).to.be.eql({[DEF_PK]: id, foo: {bar: 10}});
|
|
4002
4216
|
const oid = new ObjectId(id);
|
|
4003
4217
|
const rawData = await MDB_CLIENT.db()
|
|
4004
|
-
.collection('
|
|
4218
|
+
.collection('models')
|
|
4005
4219
|
.findOne({_id: oid});
|
|
4006
4220
|
expect(rawData).to.be.eql({_id: oid, foo: {bar: 10}});
|
|
4007
4221
|
});
|
|
@@ -4016,7 +4230,7 @@ describe('MongodbAdapter', function () {
|
|
|
4016
4230
|
expect(patched).to.be.eql({[DEF_PK]: id, foo: null});
|
|
4017
4231
|
const oid = new ObjectId(id);
|
|
4018
4232
|
const rawData = await MDB_CLIENT.db()
|
|
4019
|
-
.collection('
|
|
4233
|
+
.collection('models')
|
|
4020
4234
|
.findOne({_id: oid});
|
|
4021
4235
|
expect(rawData).to.be.eql({_id: oid, foo: null});
|
|
4022
4236
|
});
|
|
@@ -4031,7 +4245,7 @@ describe('MongodbAdapter', function () {
|
|
|
4031
4245
|
expect(patched).to.be.eql({[DEF_PK]: id, foo: null});
|
|
4032
4246
|
const oid = new ObjectId(id);
|
|
4033
4247
|
const rawData = await MDB_CLIENT.db()
|
|
4034
|
-
.collection('
|
|
4248
|
+
.collection('models')
|
|
4035
4249
|
.findOne({_id: oid});
|
|
4036
4250
|
expect(rawData).to.be.eql({_id: oid, foo: null});
|
|
4037
4251
|
});
|
|
@@ -4050,7 +4264,7 @@ describe('MongodbAdapter', function () {
|
|
|
4050
4264
|
expect(patched).to.be.eql({[DEF_PK]: id, foo: 15});
|
|
4051
4265
|
const oid = new ObjectId(id);
|
|
4052
4266
|
const rawData = await MDB_CLIENT.db()
|
|
4053
|
-
.collection('
|
|
4267
|
+
.collection('models')
|
|
4054
4268
|
.findOne({_id: oid});
|
|
4055
4269
|
expect(rawData).to.be.eql({_id: oid, foo: 15, bar: 25});
|
|
4056
4270
|
});
|
|
@@ -4069,7 +4283,7 @@ describe('MongodbAdapter', function () {
|
|
|
4069
4283
|
expect(patched).to.be.eql({[DEF_PK]: id, foo: 15, bar: 25});
|
|
4070
4284
|
const oid = new ObjectId(id);
|
|
4071
4285
|
const rawData = await MDB_CLIENT.db()
|
|
4072
|
-
.collection('
|
|
4286
|
+
.collection('models')
|
|
4073
4287
|
.findOne({_id: oid});
|
|
4074
4288
|
expect(rawData).to.be.eql({_id: oid, foo: 15, bar: 25, baz: 35});
|
|
4075
4289
|
});
|
|
@@ -4108,7 +4322,7 @@ describe('MongodbAdapter', function () {
|
|
|
4108
4322
|
expect(patched).to.be.eql({[DEF_PK]: patched[DEF_PK]});
|
|
4109
4323
|
const oid = new ObjectId(id);
|
|
4110
4324
|
const rawData = await MDB_CLIENT.db()
|
|
4111
|
-
.collection('
|
|
4325
|
+
.collection('models')
|
|
4112
4326
|
.findOne({_id: oid});
|
|
4113
4327
|
expect(rawData).to.be.eql({_id: oid, fooCol: 15, barCol: 25, bazCol: 35});
|
|
4114
4328
|
});
|
|
@@ -4123,7 +4337,7 @@ describe('MongodbAdapter', function () {
|
|
|
4123
4337
|
expect(patched).to.be.eql({[DEF_PK]: id, foo: 10});
|
|
4124
4338
|
const oid = new ObjectId(id);
|
|
4125
4339
|
const rawData = await MDB_CLIENT.db()
|
|
4126
|
-
.collection('
|
|
4340
|
+
.collection('models')
|
|
4127
4341
|
.findOne({_id: oid});
|
|
4128
4342
|
expect(rawData).to.be.eql({_id: oid, foo: 10});
|
|
4129
4343
|
});
|
|
@@ -4622,7 +4836,7 @@ describe('MongodbAdapter', function () {
|
|
|
4622
4836
|
const result = await rep.delete();
|
|
4623
4837
|
expect(result).to.be.eql(3);
|
|
4624
4838
|
const rawData = await MDB_CLIENT.db()
|
|
4625
|
-
.collection('
|
|
4839
|
+
.collection('models')
|
|
4626
4840
|
.find()
|
|
4627
4841
|
.toArray();
|
|
4628
4842
|
expect(rawData).to.be.empty;
|
|
@@ -4638,7 +4852,7 @@ describe('MongodbAdapter', function () {
|
|
|
4638
4852
|
const result = await rep.delete({foo: 10});
|
|
4639
4853
|
expect(result).to.be.eq(1);
|
|
4640
4854
|
const rawData = await MDB_CLIENT.db()
|
|
4641
|
-
.collection('
|
|
4855
|
+
.collection('models')
|
|
4642
4856
|
.find()
|
|
4643
4857
|
.toArray();
|
|
4644
4858
|
expect(rawData).to.be.eql([
|
|
@@ -4656,7 +4870,7 @@ describe('MongodbAdapter', function () {
|
|
|
4656
4870
|
const result = await rep.delete({foo: {eq: 10}});
|
|
4657
4871
|
expect(result).to.be.eq(2);
|
|
4658
4872
|
const rawData = await MDB_CLIENT.db()
|
|
4659
|
-
.collection('
|
|
4873
|
+
.collection('models')
|
|
4660
4874
|
.find()
|
|
4661
4875
|
.toArray();
|
|
4662
4876
|
expect(rawData).to.be.eql([
|
|
@@ -4674,7 +4888,7 @@ describe('MongodbAdapter', function () {
|
|
|
4674
4888
|
const result = await rep.delete({foo: {neq: 10}});
|
|
4675
4889
|
expect(result).to.be.eq(2);
|
|
4676
4890
|
const rawData = await MDB_CLIENT.db()
|
|
4677
|
-
.collection('
|
|
4891
|
+
.collection('models')
|
|
4678
4892
|
.find()
|
|
4679
4893
|
.toArray();
|
|
4680
4894
|
expect(rawData).to.be.eql([
|
|
@@ -4692,7 +4906,7 @@ describe('MongodbAdapter', function () {
|
|
|
4692
4906
|
const result = await rep.delete({foo: {gt: 10}});
|
|
4693
4907
|
expect(result).to.be.eq(1);
|
|
4694
4908
|
const rawData = await MDB_CLIENT.db()
|
|
4695
|
-
.collection('
|
|
4909
|
+
.collection('models')
|
|
4696
4910
|
.find()
|
|
4697
4911
|
.toArray();
|
|
4698
4912
|
expect(rawData).to.be.eql([
|
|
@@ -4711,7 +4925,7 @@ describe('MongodbAdapter', function () {
|
|
|
4711
4925
|
const result = await rep.delete({foo: {lt: 10}});
|
|
4712
4926
|
expect(result).to.be.eq(1);
|
|
4713
4927
|
const rawData = await MDB_CLIENT.db()
|
|
4714
|
-
.collection('
|
|
4928
|
+
.collection('models')
|
|
4715
4929
|
.find()
|
|
4716
4930
|
.toArray();
|
|
4717
4931
|
expect(rawData).to.be.eql([
|
|
@@ -4730,7 +4944,7 @@ describe('MongodbAdapter', function () {
|
|
|
4730
4944
|
const result = await rep.delete({foo: {gte: 10}});
|
|
4731
4945
|
expect(result).to.be.eq(2);
|
|
4732
4946
|
const rawData = await MDB_CLIENT.db()
|
|
4733
|
-
.collection('
|
|
4947
|
+
.collection('models')
|
|
4734
4948
|
.find()
|
|
4735
4949
|
.toArray();
|
|
4736
4950
|
expect(rawData).to.be.eql([
|
|
@@ -4748,7 +4962,7 @@ describe('MongodbAdapter', function () {
|
|
|
4748
4962
|
const result = await rep.delete({foo: {lte: 10}});
|
|
4749
4963
|
expect(result).to.be.eq(2);
|
|
4750
4964
|
const rawData = await MDB_CLIENT.db()
|
|
4751
|
-
.collection('
|
|
4965
|
+
.collection('models')
|
|
4752
4966
|
.find()
|
|
4753
4967
|
.toArray();
|
|
4754
4968
|
expect(rawData).to.be.eql([
|
|
@@ -4766,7 +4980,7 @@ describe('MongodbAdapter', function () {
|
|
|
4766
4980
|
const result = await rep.delete({foo: {inq: [5, 10]}});
|
|
4767
4981
|
expect(result).to.be.eq(2);
|
|
4768
4982
|
const rawData = await MDB_CLIENT.db()
|
|
4769
|
-
.collection('
|
|
4983
|
+
.collection('models')
|
|
4770
4984
|
.find()
|
|
4771
4985
|
.toArray();
|
|
4772
4986
|
expect(rawData).to.be.eql([
|
|
@@ -4784,7 +4998,7 @@ describe('MongodbAdapter', function () {
|
|
|
4784
4998
|
const result = await rep.delete({foo: {nin: [5, 10]}});
|
|
4785
4999
|
expect(result).to.be.eq(1);
|
|
4786
5000
|
const rawData = await MDB_CLIENT.db()
|
|
4787
|
-
.collection('
|
|
5001
|
+
.collection('models')
|
|
4788
5002
|
.find()
|
|
4789
5003
|
.toArray();
|
|
4790
5004
|
expect(rawData).to.be.eql([
|
|
@@ -4804,7 +5018,7 @@ describe('MongodbAdapter', function () {
|
|
|
4804
5018
|
const result = await rep.delete({foo: {between: [9, 16]}});
|
|
4805
5019
|
expect(result).to.be.eq(2);
|
|
4806
5020
|
const rawData = await MDB_CLIENT.db()
|
|
4807
|
-
.collection('
|
|
5021
|
+
.collection('models')
|
|
4808
5022
|
.find()
|
|
4809
5023
|
.toArray();
|
|
4810
5024
|
expect(rawData).to.be.eql([
|
|
@@ -4825,7 +5039,7 @@ describe('MongodbAdapter', function () {
|
|
|
4825
5039
|
const result = await rep.delete({foo: {exists: true}});
|
|
4826
5040
|
expect(result).to.be.eq(3);
|
|
4827
5041
|
const rawData = await MDB_CLIENT.db()
|
|
4828
|
-
.collection('
|
|
5042
|
+
.collection('models')
|
|
4829
5043
|
.find()
|
|
4830
5044
|
.toArray();
|
|
4831
5045
|
expect(rawData).to.be.eql([{_id: new ObjectId(id1)}]);
|
|
@@ -4845,7 +5059,7 @@ describe('MongodbAdapter', function () {
|
|
|
4845
5059
|
const result = await rep.delete({foo: {exists: false}});
|
|
4846
5060
|
expect(result).to.be.eq(1);
|
|
4847
5061
|
const rawData = await MDB_CLIENT.db()
|
|
4848
|
-
.collection('
|
|
5062
|
+
.collection('models')
|
|
4849
5063
|
.find()
|
|
4850
5064
|
.toArray();
|
|
4851
5065
|
expect(rawData).to.be.eql([
|
|
@@ -4866,7 +5080,7 @@ describe('MongodbAdapter', function () {
|
|
|
4866
5080
|
const result = await rep.delete({foo: {like: 'sit amet'}});
|
|
4867
5081
|
expect(result).to.be.eq(2);
|
|
4868
5082
|
const rawData = await MDB_CLIENT.db()
|
|
4869
|
-
.collection('
|
|
5083
|
+
.collection('models')
|
|
4870
5084
|
.find()
|
|
4871
5085
|
.toArray();
|
|
4872
5086
|
expect(rawData).to.be.eql([
|
|
@@ -4886,7 +5100,7 @@ describe('MongodbAdapter', function () {
|
|
|
4886
5100
|
const result = await rep.delete({foo: {nlike: 'sit amet'}});
|
|
4887
5101
|
expect(result).to.be.eq(2);
|
|
4888
5102
|
const rawData = await MDB_CLIENT.db()
|
|
4889
|
-
.collection('
|
|
5103
|
+
.collection('models')
|
|
4890
5104
|
.find()
|
|
4891
5105
|
.toArray();
|
|
4892
5106
|
expect(rawData).to.be.eql([
|
|
@@ -4906,7 +5120,7 @@ describe('MongodbAdapter', function () {
|
|
|
4906
5120
|
const result = await rep.delete({foo: {ilike: 'sit amet'}});
|
|
4907
5121
|
expect(result).to.be.eq(3);
|
|
4908
5122
|
const rawData = await MDB_CLIENT.db()
|
|
4909
|
-
.collection('
|
|
5123
|
+
.collection('models')
|
|
4910
5124
|
.find()
|
|
4911
5125
|
.toArray();
|
|
4912
5126
|
expect(rawData).to.be.eql([
|
|
@@ -4925,7 +5139,7 @@ describe('MongodbAdapter', function () {
|
|
|
4925
5139
|
const result = await rep.delete({foo: {nilike: 'sit amet'}});
|
|
4926
5140
|
expect(result).to.be.eq(1);
|
|
4927
5141
|
const rawData = await MDB_CLIENT.db()
|
|
4928
|
-
.collection('
|
|
5142
|
+
.collection('models')
|
|
4929
5143
|
.find()
|
|
4930
5144
|
.toArray();
|
|
4931
5145
|
expect(rawData).to.be.eql([
|
|
@@ -4946,7 +5160,7 @@ describe('MongodbAdapter', function () {
|
|
|
4946
5160
|
const result = await rep.delete({foo: {regexp: 'sit am+'}});
|
|
4947
5161
|
expect(result).to.be.eq(2);
|
|
4948
5162
|
const rawData = await MDB_CLIENT.db()
|
|
4949
|
-
.collection('
|
|
5163
|
+
.collection('models')
|
|
4950
5164
|
.find()
|
|
4951
5165
|
.toArray();
|
|
4952
5166
|
expect(rawData).to.be.eql([
|
|
@@ -4966,7 +5180,7 @@ describe('MongodbAdapter', function () {
|
|
|
4966
5180
|
const result = await rep.delete({foo: {regexp: 'sit am+', flags: 'i'}});
|
|
4967
5181
|
expect(result).to.be.eq(3);
|
|
4968
5182
|
const rawData = await MDB_CLIENT.db()
|
|
4969
|
-
.collection('
|
|
5183
|
+
.collection('models')
|
|
4970
5184
|
.find()
|
|
4971
5185
|
.toArray();
|
|
4972
5186
|
expect(rawData).to.be.eql([
|
|
@@ -4995,7 +5209,7 @@ describe('MongodbAdapter', function () {
|
|
|
4995
5209
|
const result = await rep.deleteById(oid);
|
|
4996
5210
|
expect(result).to.be.true;
|
|
4997
5211
|
const rawData = await MDB_CLIENT.db()
|
|
4998
|
-
.collection('
|
|
5212
|
+
.collection('models')
|
|
4999
5213
|
.find()
|
|
5000
5214
|
.toArray();
|
|
5001
5215
|
expect(rawData).to.be.empty;
|