sorla-db 1.0.0 → 1.1.0

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.
@@ -1,269 +1,224 @@
1
- const chai = require('chai')
2
- const expect = chai.expect
3
- const faker = require('faker')
4
- const sorla = require('../src/sorla.js')
5
- const helper = require('../src/helper.js')
6
-
7
- describe('SORLA Collection Queries Feature Test', () => {
8
- beforeAll(() => {
9
- this.srla = new sorla();
10
- this.dbname = faker.random.word();
11
- this.srla.createDb(this.dbname);
12
- this.srla.useDb(this.dbname);
13
- this.collectionName = faker.random.word();
14
- this.srla.db.createCollection(this.collectionName);
15
- this.objects = helper.createFakeCollection(this.srla, this.collectionName, 30);
16
- });
17
-
18
- it('Test if the first document in the collection is the same first document on the objects array', () => {
19
- const firstDoc = this.srla.db[this.collectionName].findOne({}, { _id: 0 });
20
- const firstObj = this.objects[0];
21
- expect(firstDoc).to.deep.equal(firstObj);
22
- });
23
-
24
- it('Takes the data field name from the document inside the collection', () => {
25
- const firstDoc = this.srla.db[this.collectionName].findOne({}, { _id: 0 });
26
- const firstObj = this.objects[0];
27
- expect(firstDoc.name).to.be.a('string').equal(firstObj.name);
28
- });
29
-
30
- it('Takes the data field email from the document inside the collection', () => {
31
- const firstDoc = this.srla.db[this.collectionName].findOne({}, { _id: 0 });
32
- const firstObj = this.objects[0];
33
- expect(firstDoc.email).to.be.a('string').equal(firstObj.email);
34
- });
35
-
36
- it('Takes the data field age from the document inside the collection', () => {
37
- const firstDoc = this.srla.db[this.collectionName].findOne({}, { _id: 0 });
38
- const firstObj = this.objects[0];
39
- expect(firstDoc.age).to.be.a('number').equal(firstObj.age);
40
- });
41
-
42
- it('Creates a few documents and search for one of them', () => {
43
- const [item1,] = helper.getRandomComparisonData(this.objects);
44
- const doc = this.srla.db[this.collectionName].findOne({ uuid: item1.uuid }, { _id: 0 });
45
- expect(doc).to.deep.equal(item1);
46
- });
47
-
48
- it('Creates a few documents and search for some of them', () => {
49
- const [item1, item2] = helper.getRandomComparisonData(this.objects);
50
- const docs = this.srla.db[this.collectionName].find({
51
- $or: [
52
- { uuid: item1.uuid },
53
- { uuid: item2.uuid }
54
- ]
55
- });
56
-
57
- expect(docs.length).to.be.equal(2);
58
- });
59
-
60
- it('Creates a few documents and search using not', () => {
61
- const [item1] = helper.getRandomComparisonData(this.objects);
62
- const docs = this.srla.db[this.collectionName].find(
63
- {
64
- uuid: {
65
- $not: {
66
- $eq: item1.uuid
67
- }
68
- }
69
- }
70
- );
71
-
72
- expect(docs.length).to.be.equal(this.objects.length - 1);
73
- });
74
-
75
- it('Creates a few documents and search using not with more than one expression', () => {
76
- const [item1,] = helper.getRandomComparisonData(this.objects);
77
- const docs = this.srla.db[this.collectionName].find(
78
- {
79
- age: {
80
- $not: {
81
- $eq: item1.age,
82
- $gt: 18
83
- }
84
- }
85
- }
86
- );
87
-
88
- expect(docs.length).to.be.equal(this.objects.length - 1);
89
- });
90
-
91
- it('Creates a few documents and search it using nor', () => {
92
- const [item1,] = helper.getRandomComparisonData(this.objects);
93
- const docs = this.srla.db[this.collectionName].findOne({
94
- $nor: [
95
- {name: item1.name},
96
- {age: item1.age}
97
- ]
98
- });
99
-
100
- expect(docs.name).to.not.be.equal(item1.name);
101
- expect(docs.age).to.not.be.equal(item1.age);
102
- });
103
-
104
- it('Creates a few documents and search it using nor with more than one expression', () => {
105
- const [item1, item2] = helper.getRandomComparisonData(this.objects);
106
- const docs = this.srla.db[this.collectionName].find({
107
- $nor: [
108
- {name: item1.name},
109
- {age: item1.age},
110
- {name: item2.name},
111
- {age: item2.age}
112
- ]
113
- });
114
-
115
- expect(docs.length).to.be.equal(this.objects.length - 2);
116
- });
117
-
118
- it('Test sort number in ascending order', () => {
119
- this.srla.db.createCollection('sortNumberAsc');
120
- this.srla.db.sortNumberAsc.insertMany([
121
- {
122
- name: 'A',
123
- age: 20
124
- },
125
- {
126
- name: 'B',
127
- age: 10
128
- },
129
- {
130
- name: 'C',
131
- age: 30
132
- },
133
- {
134
- name: 'A',
135
- age: 3
136
- },
137
- {
138
- name: 'B',
139
- age: 5
140
- },
141
- {
142
- name: 'C',
143
- age: 1
144
- },
145
- ]);
146
- });
147
-
148
- it('Test sort number in descending order', () => {
149
- });
150
-
151
- it('Test sort string in ascending order', () => {
152
- });
153
-
154
- it('Test sort string in descending order', () => {
155
- });
156
-
157
- it('Test sort date in ascending order', () => {
158
- });
159
-
160
- it('Test sort date in descending order', () => {
161
- });
162
-
163
- it('Test sort boolean in ascending order', () => {
164
- });
165
-
166
- it('Test sort boolean in descending order', () => {
167
- });
168
-
169
- it('Test equal comparison', () => {
170
- const [item1,] = helper.getRandomComparisonData(this.objects);
171
- const doc = this.srla.db[this.collectionName].findOne({ uuid: item1.uuid }, { _id: 0 });
172
- expect(doc).to.deep.equal(item1);
173
- });
174
-
175
- it('Test not equal comparison', () => {
176
- const [item1,] = helper.getRandomComparisonData(this.objects);
177
- const docs = this.srla.db[this.collectionName].find({
178
- uuid: { $ne: item1.uuid }
179
- });
180
-
181
- expect(docs.length).to.be.equal(this.objects.length - 1);
182
- });
183
-
184
- it('Test greater than comparison', () => {
185
- const [item1,] = helper.getRandomComparisonData(this.objects);
186
- const docs = this.srla.db[this.collectionName].find({
187
- age: { $gt: item1.age }
188
- });
189
-
190
- countAges = this.objects.filter(obj => obj.age > item1.age).length;
191
- expect(docs.length).to.be.equal(countAges);
192
- });
193
-
194
- it('Test greater than or equal comparison', () => {
195
- const [item1,] = helper.getRandomComparisonData(this.objects);
196
- const docs = this.srla.db[this.collectionName].find({
197
- age: { $gte: item1.age }
198
- });
199
-
200
- countAges = this.objects.filter(obj => obj.age >= item1.age).length;
201
- expect(docs.length).to.be.equal(countAges);
202
- });
203
-
204
- it('Test less than comparison', () => {
205
- const [item1,] = helper.getRandomComparisonData(this.objects);
206
- const docs = this.srla.db[this.collectionName].find({
207
- age: { $lt: item1.age }
208
- });
209
-
210
- countAges = this.objects.filter(obj => obj.age < item1.age).length;
211
- expect(docs.length).to.be.equal(countAges);
212
- });
213
-
214
- it('Test less than or equal comparison', () => {
215
- const [item1,] = helper.getRandomComparisonData(this.objects);
216
- const docs = this.srla.db[this.collectionName].find({
217
- age: { $lte: item1.age }
218
- });
219
-
220
- countAges = this.objects.filter(obj => obj.age <= item1.age).length;
221
- expect(docs.length).to.be.equal(countAges);
222
- });
223
-
224
- it('Test in comparison', () => {
225
- const [item1, item2] = helper.getRandomComparisonData(this.objects);
226
- const docs = this.srla.db[this.collectionName].find({
227
- age: { $in: [item1.age, item2.age] }
228
- });
229
-
230
- countAges = this.objects.filter(obj => obj.age === item1.age || obj.age === item2.age).length;
231
- expect(docs.length).to.be.equal(countAges);
232
- });
233
-
234
- it('Test not in comparison', () => {
235
- const [item1, item2] = helper.getRandomComparisonData(this.objects);
236
- const docs = this.srla.db[this.collectionName].find({
237
- age: { $nin: [item1.age, item2.age] }
238
- });
239
-
240
- countAges = this.objects.filter(obj => obj.age !== item1.age && obj.age !== item2.age).length;
241
- expect(docs.length).to.be.equal(countAges);
242
- });
243
-
244
- it('Test mixed comparison with and', () => {
245
- const [item1,] = helper.getRandomComparisonData(this.objects);
246
- const docs = this.srla.db[this.collectionName].find({
247
- $and: [
248
- { name: item1.name },
249
- { age: item1.age }
250
- ]
251
- });
252
-
253
- const filtered = this.objects.filter(obj => obj.name === item1.name && obj.age === item1.age);
254
- expect(docs.length).to.be.equal(filtered.length);
255
- });
256
-
257
- it('Test mixed comparison with or', () => {
258
- const [item1, item2] = helper.getRandomComparisonData(this.objects);
259
- const docs = this.srla.db[this.collectionName].find({
260
- $or: [
261
- { name: item1.name },
262
- { age: item2.age }
263
- ]
264
- });
265
-
266
- const filtered = this.objects.filter(obj => obj.name === item1.name || obj.age === item2.age);
267
- expect(docs.length).to.be.equal(filtered.length);
268
- });
1
+ const chai = require('chai')
2
+ const expect = chai.expect
3
+ const faker = require('faker')
4
+ const sorla = require('../src/sorla.js')
5
+ const helper = require('../src/helper.js')
6
+
7
+ describe('SORLA Collection Queries Feature Test', () => {
8
+ beforeAll(() => {
9
+ this.srla = new sorla();
10
+ this.dbname = faker.random.word();
11
+ this.srla.createDb(this.dbname);
12
+ this.srla.useDb(this.dbname);
13
+ this.collectionName = faker.random.word();
14
+ this.srla.db.createCollection(this.collectionName);
15
+ this.objects = helper.createFakeCollection(this.srla, this.collectionName, 30);
16
+ });
17
+
18
+ it('Test if the first document in the collection is the same first document on the objects array', () => {
19
+ const firstDoc = this.srla.db[this.collectionName].findOne({}, { _id: 0 });
20
+ const firstObj = this.objects[0];
21
+ expect(firstDoc).to.deep.equal(firstObj);
22
+ });
23
+
24
+ it('Takes the data field name from the document inside the collection', () => {
25
+ const firstDoc = this.srla.db[this.collectionName].findOne({}, { _id: 0 });
26
+ const firstObj = this.objects[0];
27
+ expect(firstDoc.name).to.be.a('string').equal(firstObj.name);
28
+ });
29
+
30
+ it('Takes the data field email from the document inside the collection', () => {
31
+ const firstDoc = this.srla.db[this.collectionName].findOne({}, { _id: 0 });
32
+ const firstObj = this.objects[0];
33
+ expect(firstDoc.email).to.be.a('string').equal(firstObj.email);
34
+ });
35
+
36
+ it('Takes the data field age from the document inside the collection', () => {
37
+ const firstDoc = this.srla.db[this.collectionName].findOne({}, { _id: 0 });
38
+ const firstObj = this.objects[0];
39
+ expect(firstDoc.age).to.be.a('number').equal(firstObj.age);
40
+ });
41
+
42
+ it('Creates a few documents and search for one of them', () => {
43
+ const [item1,] = helper.getRandomComparisonData(this.objects);
44
+ const doc = this.srla.db[this.collectionName].findOne({ uuid: item1.uuid }, { _id: 0 });
45
+ expect(doc).to.deep.equal(item1);
46
+ });
47
+
48
+ it('Creates a few documents and search for some of them', () => {
49
+ const [item1, item2] = helper.getRandomComparisonData(this.objects);
50
+ const docs = this.srla.db[this.collectionName].find({
51
+ $or: [
52
+ { uuid: item1.uuid },
53
+ { uuid: item2.uuid }
54
+ ]
55
+ });
56
+
57
+ expect(docs.length).to.be.equal(2);
58
+ });
59
+
60
+ it('Creates a few documents and search using not', () => {
61
+ const [item1] = helper.getRandomComparisonData(this.objects);
62
+ const docs = this.srla.db[this.collectionName].find(
63
+ {
64
+ uuid: {
65
+ $not: {
66
+ $eq: item1.uuid
67
+ }
68
+ }
69
+ }
70
+ );
71
+
72
+ expect(docs.length).to.be.equal(this.objects.length - 1);
73
+ });
74
+
75
+ it('Creates a few documents and search using not with more than one expression', () => {
76
+ const [item1,] = helper.getRandomComparisonData(this.objects);
77
+ const docs = this.srla.db[this.collectionName].find(
78
+ {
79
+ age: {
80
+ $not: {
81
+ $eq: item1.age,
82
+ $gt: 18
83
+ }
84
+ }
85
+ }
86
+ );
87
+
88
+ // $not negates the whole condition: excluded when age equals item1.age AND is over 18
89
+ const expected = this.objects.filter(obj => !(obj.age === item1.age && obj.age > 18));
90
+ expect(docs.length).to.be.equal(expected.length);
91
+ });
92
+
93
+ it('Creates a few documents and search it using nor', () => {
94
+ const [item1,] = helper.getRandomComparisonData(this.objects);
95
+ const docs = this.srla.db[this.collectionName].findOne({
96
+ $nor: [
97
+ {name: item1.name},
98
+ {age: item1.age}
99
+ ]
100
+ });
101
+
102
+ expect(docs.name).to.not.be.equal(item1.name);
103
+ expect(docs.age).to.not.be.equal(item1.age);
104
+ });
105
+
106
+ it('Creates a few documents and search it using nor with more than one expression', () => {
107
+ const [item1, item2] = helper.getRandomComparisonData(this.objects);
108
+ const docs = this.srla.db[this.collectionName].find({
109
+ $nor: [
110
+ {name: item1.name},
111
+ {age: item1.age},
112
+ {name: item2.name},
113
+ {age: item2.age}
114
+ ]
115
+ });
116
+
117
+ // random names and ages can repeat, so count the expected documents instead of assuming 2
118
+ const expected = this.objects.filter(obj => obj.name !== item1.name && obj.age !== item1.age && obj.name !== item2.name && obj.age !== item2.age);
119
+ expect(docs.length).to.be.equal(expected.length);
120
+ });
121
+
122
+ // sorting is covered by test/feature_cursor.test.js
123
+
124
+ it('Test equal comparison', () => {
125
+ const [item1,] = helper.getRandomComparisonData(this.objects);
126
+ const doc = this.srla.db[this.collectionName].findOne({ uuid: item1.uuid }, { _id: 0 });
127
+ expect(doc).to.deep.equal(item1);
128
+ });
129
+
130
+ it('Test not equal comparison', () => {
131
+ const [item1,] = helper.getRandomComparisonData(this.objects);
132
+ const docs = this.srla.db[this.collectionName].find({
133
+ uuid: { $ne: item1.uuid }
134
+ });
135
+
136
+ expect(docs.length).to.be.equal(this.objects.length - 1);
137
+ });
138
+
139
+ it('Test greater than comparison', () => {
140
+ const [item1,] = helper.getRandomComparisonData(this.objects);
141
+ const docs = this.srla.db[this.collectionName].find({
142
+ age: { $gt: item1.age }
143
+ });
144
+
145
+ countAges = this.objects.filter(obj => obj.age > item1.age).length;
146
+ expect(docs.length).to.be.equal(countAges);
147
+ });
148
+
149
+ it('Test greater than or equal comparison', () => {
150
+ const [item1,] = helper.getRandomComparisonData(this.objects);
151
+ const docs = this.srla.db[this.collectionName].find({
152
+ age: { $gte: item1.age }
153
+ });
154
+
155
+ countAges = this.objects.filter(obj => obj.age >= item1.age).length;
156
+ expect(docs.length).to.be.equal(countAges);
157
+ });
158
+
159
+ it('Test less than comparison', () => {
160
+ const [item1,] = helper.getRandomComparisonData(this.objects);
161
+ const docs = this.srla.db[this.collectionName].find({
162
+ age: { $lt: item1.age }
163
+ });
164
+
165
+ countAges = this.objects.filter(obj => obj.age < item1.age).length;
166
+ expect(docs.length).to.be.equal(countAges);
167
+ });
168
+
169
+ it('Test less than or equal comparison', () => {
170
+ const [item1,] = helper.getRandomComparisonData(this.objects);
171
+ const docs = this.srla.db[this.collectionName].find({
172
+ age: { $lte: item1.age }
173
+ });
174
+
175
+ countAges = this.objects.filter(obj => obj.age <= item1.age).length;
176
+ expect(docs.length).to.be.equal(countAges);
177
+ });
178
+
179
+ it('Test in comparison', () => {
180
+ const [item1, item2] = helper.getRandomComparisonData(this.objects);
181
+ const docs = this.srla.db[this.collectionName].find({
182
+ age: { $in: [item1.age, item2.age] }
183
+ });
184
+
185
+ countAges = this.objects.filter(obj => obj.age === item1.age || obj.age === item2.age).length;
186
+ expect(docs.length).to.be.equal(countAges);
187
+ });
188
+
189
+ it('Test not in comparison', () => {
190
+ const [item1, item2] = helper.getRandomComparisonData(this.objects);
191
+ const docs = this.srla.db[this.collectionName].find({
192
+ age: { $nin: [item1.age, item2.age] }
193
+ });
194
+
195
+ countAges = this.objects.filter(obj => obj.age !== item1.age && obj.age !== item2.age).length;
196
+ expect(docs.length).to.be.equal(countAges);
197
+ });
198
+
199
+ it('Test mixed comparison with and', () => {
200
+ const [item1,] = helper.getRandomComparisonData(this.objects);
201
+ const docs = this.srla.db[this.collectionName].find({
202
+ $and: [
203
+ { name: item1.name },
204
+ { age: item1.age }
205
+ ]
206
+ });
207
+
208
+ const filtered = this.objects.filter(obj => obj.name === item1.name && obj.age === item1.age);
209
+ expect(docs.length).to.be.equal(filtered.length);
210
+ });
211
+
212
+ it('Test mixed comparison with or', () => {
213
+ const [item1, item2] = helper.getRandomComparisonData(this.objects);
214
+ const docs = this.srla.db[this.collectionName].find({
215
+ $or: [
216
+ { name: item1.name },
217
+ { age: item2.age }
218
+ ]
219
+ });
220
+
221
+ const filtered = this.objects.filter(obj => obj.name === item1.name || obj.age === item2.age);
222
+ expect(docs.length).to.be.equal(filtered.length);
223
+ });
269
224
  });
@@ -0,0 +1,84 @@
1
+ const chai = require('chai')
2
+ const expect = chai.expect
3
+ const sorla = require('../src/sorla.js')
4
+
5
+ describe('SORLA cursor', () => {
6
+ let people;
7
+
8
+ beforeAll(() => {
9
+ const srla = new sorla();
10
+ srla.useDb('cursor');
11
+ srla.db.createCollection('people');
12
+ people = srla.db.people;
13
+ for(const [name, age] of [['Carla', 42], ['Ana', 25], ['Bruno', 31]])
14
+ people.insertOne({ name, age, email: `${name.toLowerCase()}@mail.com` });
15
+ // projection logs every removed property
16
+ jest.spyOn(console, 'log').mockImplementation(() => {});
17
+ });
18
+
19
+ afterAll(() => jest.restoreAllMocks());
20
+
21
+ it('iterates with hasNext/next and can be reset', () => {
22
+ const cursor = people.find({});
23
+ expect(cursor.length).to.equal(3);
24
+ const names = [];
25
+ while(cursor.hasNext()) names.push(cursor.next()._data.name);
26
+ expect(names).to.deep.equal(['Carla', 'Ana', 'Bruno']);
27
+ expect(() => cursor.next()).to.throw('No more item to the cursor');
28
+ cursor.reset();
29
+ expect(cursor.next()._data.name).to.equal('Carla');
30
+ });
31
+
32
+ it('first() returns the data of the first document', () => {
33
+ expect(people.find({ age: { $gt: 30 } }).first().name).to.equal('Carla');
34
+ });
35
+
36
+ it('returns copies: changing a result does not change the collection', () => {
37
+ const cursor = people.find({ name: 'Ana' });
38
+ cursor.next()._data.age = 99;
39
+ expect(people.findOne({ name: 'Ana' }).age).to.equal(25);
40
+ });
41
+
42
+ it('projection with 0 removes fields from the results only', () => {
43
+ const cursor = people.find({ name: 'Ana' }, { email: 0 });
44
+ expect(cursor.next()._data).to.not.have.property('email');
45
+ expect(people.findOne({ name: 'Ana' }).email).to.equal('ana@mail.com');
46
+ });
47
+
48
+ it('last() gives access to the fields of the last document', () => {
49
+ expect(people.find({}).last().name).to.equal('Bruno');
50
+ });
51
+
52
+ it('push only accepts objects', () => {
53
+ const cursor = people.find({});
54
+ expect(() => cursor.push('x')).to.throw('The element must be an object');
55
+ cursor.push({ name: 'Extra' });
56
+ expect(cursor.length).to.equal(4);
57
+ });
58
+
59
+ // ---- known bugs: these document current behavior and will start failing once fixed
60
+
61
+ it.failing('sorts by a number ascending (cursor.js/document.js circular require)', () => {
62
+ const cursor = people.find({});
63
+ cursor.sort({ age: 1 });
64
+ expect(cursor.first().name).to.equal('Ana');
65
+ });
66
+
67
+ it.failing('sorts by several fields descending', () => {
68
+ const cursor = people.find({});
69
+ cursor.sort({ age: -1, name: 1 });
70
+ expect(cursor.first().name).to.equal('Carla');
71
+ });
72
+
73
+ it.failing('toArray returns plain objects (structuredClone of a Proxy)', () => {
74
+ expect(people.find({}).toArray().map(doc => doc.name)).to.deep.equal(['Carla', 'Ana', 'Bruno']);
75
+ });
76
+
77
+ it.failing('findOne returns null when nothing matches', () => {
78
+ expect(people.findOne({ name: 'Nobody' })).to.equal(null);
79
+ });
80
+
81
+
82
+ it.todo('projection with 1 keeps only the listed fields');
83
+ it.todo('skip() and limit()');
84
+ });
@@ -0,0 +1,62 @@
1
+ const chai = require('chai')
2
+ const expect = chai.expect
3
+ const sorla = require('../src/sorla.js')
4
+
5
+ describe('SORLA databases and collections', () => {
6
+ it('useDb creates the database when needed and selects it', () => {
7
+ const srla = new sorla();
8
+ expect(srla.dbExists('shop')).to.equal(false);
9
+ srla.useDb('shop');
10
+ expect(srla.dbExists('shop')).to.equal(true);
11
+ expect(srla.db.name).to.equal('shop');
12
+ expect(srla.countDb()).to.equal(1);
13
+ });
14
+
15
+ it('createDb returns the position, or false when the name exists', () => {
16
+ const srla = new sorla();
17
+ expect(srla.createDb('a')).to.equal(0);
18
+ expect(srla.createDb('b')).to.equal(1);
19
+ expect(srla.createDb('a')).to.equal(false);
20
+ });
21
+
22
+ it('keeps databases and their collections isolated', () => {
23
+ const srla = new sorla();
24
+ srla.useDb('one');
25
+ srla.db.createCollection('items');
26
+ srla.db.items.insertOne({ n: 1 });
27
+ srla.useDb('two');
28
+ srla.db.createCollection('items');
29
+ expect(srla.db.items.count()).to.equal(0);
30
+ srla.useDb('one');
31
+ expect(srla.db.items.count()).to.equal(1);
32
+ });
33
+
34
+ it('instances do not share data', () => {
35
+ const a = new sorla();
36
+ const b = new sorla();
37
+ a.useDb('x');
38
+ expect(b.dbExists('x')).to.equal(false);
39
+ });
40
+
41
+ it('rejects duplicated collection names', () => {
42
+ const srla = new sorla();
43
+ srla.useDb('dupes');
44
+ srla.db.createCollection('items');
45
+ expect(() => srla.db.createCollection('items')).to.throw('Collection already exists');
46
+ expect(srla.db.countCollections()).to.equal(1);
47
+ });
48
+
49
+ it('collection count, first, last and all', () => {
50
+ const srla = new sorla();
51
+ srla.useDb('basics');
52
+ srla.db.createCollection('items');
53
+ const items = srla.db.items;
54
+ expect(items.count()).to.equal(0);
55
+ items.insertOne({ n: 1 });
56
+ items.insertOne({ n: 2 });
57
+ expect(items.count()).to.equal(2);
58
+ expect(items.first.n).to.equal(1);
59
+ expect(items.last.n).to.equal(2);
60
+ expect(items.all.length).to.equal(2);
61
+ });
62
+ });