UNPKG

67.2 kBHTMLView Raw
1<!DOCTYPE html>
2<html lang="en">
3<head>
4 <meta charset="utf-8">
5 <title>JSDoc: Class: Collection</title>
6
7 <script src="scripts/prettify/prettify.js"> </script>
8 <script src="scripts/prettify/lang-css.js"> </script>
9 <!--[if lt IE 9]>
10 <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11 <![endif]-->
12 <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
13 <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
14</head>
15
16<body>
17
18<div id="main">
19
20 <h1 class="page-title">Class: Collection</h1>
21
22
23
24
25
26
27<section>
28
29<header>
30
31 <h2>Collection</h2>
32
33
34</header>
35
36<article>
37 <div class="container-overview">
38
39
40
41
42
43 <h4 class="name" id="Collection"><span class="type-signature"></span>new Collection<span class="signature">(name, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
44
45
46
47
48
49<div class="description">
50 <p>Collection class that handles documents of same type</p>
51</div>
52
53
54
55
56
57
58
59
60
61 <h5>Parameters:</h5>
62
63
64<table class="params">
65 <thead>
66 <tr>
67
68 <th>Name</th>
69
70
71 <th>Type</th>
72
73
74 <th>Attributes</th>
75
76
77
78
79 <th class="last">Description</th>
80 </tr>
81 </thead>
82
83 <tbody>
84
85
86 <tr>
87
88 <td class="name"><code>name</code></td>
89
90
91 <td class="type">
92
93
94<span class="param-type">string</span>
95
96
97
98 </td>
99
100
101 <td class="attributes">
102
103
104
105
106
107 </td>
108
109
110
111
112 <td class="description last"><p>collection name</p></td>
113 </tr>
114
115
116
117 <tr>
118
119 <td class="name"><code>options</code></td>
120
121
122 <td class="type">
123
124
125<span class="param-type">array</span>
126|
127
128<span class="param-type">object</span>
129
130
131
132 </td>
133
134
135 <td class="attributes">
136
137 &lt;optional><br>
138
139
140
141
142
143 </td>
144
145
146
147
148 <td class="description last"><p>(optional) array of property names to be indicized OR a configuration object</p>
149 <h6>Properties</h6>
150
151
152<table class="params">
153 <thead>
154 <tr>
155
156 <th>Name</th>
157
158
159 <th>Type</th>
160
161
162
163
164
165 <th class="last">Description</th>
166 </tr>
167 </thead>
168
169 <tbody>
170
171
172 <tr>
173
174 <td class="name"><code>unique</code></td>
175
176
177 <td class="type">
178
179
180<span class="param-type">array</span>
181
182
183
184 </td>
185
186
187
188
189
190 <td class="description last"><p>array of property names to define unique constraints for</p></td>
191 </tr>
192
193
194
195 <tr>
196
197 <td class="name"><code>exact</code></td>
198
199
200 <td class="type">
201
202
203<span class="param-type">array</span>
204
205
206
207 </td>
208
209
210
211
212
213 <td class="description last"><p>array of property names to define exact constraints for</p></td>
214 </tr>
215
216
217
218 <tr>
219
220 <td class="name"><code>indices</code></td>
221
222
223 <td class="type">
224
225
226<span class="param-type">array</span>
227
228
229
230 </td>
231
232
233
234
235
236 <td class="description last"><p>array property names to define binary indexes for</p></td>
237 </tr>
238
239
240
241 <tr>
242
243 <td class="name"><code>adaptiveBinaryIndices</code></td>
244
245
246 <td class="type">
247
248
249<span class="param-type">boolean</span>
250
251
252
253 </td>
254
255
256
257
258
259 <td class="description last"><p>collection indices will be actively rebuilt rather than lazily (default: true)</p></td>
260 </tr>
261
262
263
264 <tr>
265
266 <td class="name"><code>asyncListeners</code></td>
267
268
269 <td class="type">
270
271
272<span class="param-type">boolean</span>
273
274
275
276 </td>
277
278
279
280
281
282 <td class="description last"><p>default is false</p></td>
283 </tr>
284
285
286
287 <tr>
288
289 <td class="name"><code>disableChangesApi</code></td>
290
291
292 <td class="type">
293
294
295<span class="param-type">boolean</span>
296
297
298
299 </td>
300
301
302
303
304
305 <td class="description last"><p>default is true</p></td>
306 </tr>
307
308
309
310 <tr>
311
312 <td class="name"><code>autoupdate</code></td>
313
314
315 <td class="type">
316
317
318<span class="param-type">boolean</span>
319
320
321
322 </td>
323
324
325
326
327
328 <td class="description last"><p>use Object.observe to update objects automatically (default: false)</p></td>
329 </tr>
330
331
332
333 <tr>
334
335 <td class="name"><code>clone</code></td>
336
337
338 <td class="type">
339
340
341<span class="param-type">boolean</span>
342
343
344
345 </td>
346
347
348
349
350
351 <td class="description last"><p>specify whether inserts and queries clone to/from user</p></td>
352 </tr>
353
354
355
356 <tr>
357
358 <td class="name"><code>cloneMethod</code></td>
359
360
361 <td class="type">
362
363
364<span class="param-type">string</span>
365
366
367
368 </td>
369
370
371
372
373
374 <td class="description last"><p>'parse-stringify' (default), 'jquery-extend-deep', 'shallow'</p></td>
375 </tr>
376
377
378
379 <tr>
380
381 <td class="name"><code>ttlInterval</code></td>
382
383
384 <td class="type">
385
386
387<span class="param-type">int</span>
388
389
390
391 </td>
392
393
394
395
396
397 <td class="description last"><p>time interval for clearing out 'aged' documents; not set by default.</p></td>
398 </tr>
399
400
401 </tbody>
402</table>
403
404 </td>
405 </tr>
406
407
408 </tbody>
409</table>
410
411
412
413
414
415
416<dl class="details">
417
418
419
420
421
422
423
424
425
426
427
428
429 <dt class="implements">Implements:</dt>
430 <dd class="implements"><ul>
431
432 <li><a href="LokiEventEmitter.html">LokiEventEmitter</a></li>
433
434 </ul></dd>
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450 <dt class="tag-source">Source:</dt>
451 <dd class="tag-source"><ul class="dummy"><li>
452 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line3972">line 3972</a>
453 </li></ul></dd>
454
455
456
457
458
459 <dt class="tag-see">See:</dt>
460 <dd class="tag-see">
461 <ul>
462 <li><a href="Loki.html#addCollection">Loki#addCollection</a> for normal creation of collections</li>
463 </ul>
464 </dd>
465
466
467
468</dl>
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486 </div>
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501 <h3 class="subsection-title">Methods</h3>
502
503
504
505
506
507
508 <h4 class="name" id="addDynamicView"><span class="type-signature"></span>addDynamicView<span class="signature">(name, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {<a href="DynamicView.html">DynamicView</a>}</span></h4>
509
510
511
512
513
514<div class="description">
515 <p>Add a dynamic view to the collection</p>
516</div>
517
518
519
520
521
522
523
524
525
526 <h5>Parameters:</h5>
527
528
529<table class="params">
530 <thead>
531 <tr>
532
533 <th>Name</th>
534
535
536 <th>Type</th>
537
538
539 <th>Attributes</th>
540
541
542
543
544 <th class="last">Description</th>
545 </tr>
546 </thead>
547
548 <tbody>
549
550
551 <tr>
552
553 <td class="name"><code>name</code></td>
554
555
556 <td class="type">
557
558
559<span class="param-type">string</span>
560
561
562
563 </td>
564
565
566 <td class="attributes">
567
568
569
570
571
572 </td>
573
574
575
576
577 <td class="description last"><p>name of dynamic view to add</p></td>
578 </tr>
579
580
581
582 <tr>
583
584 <td class="name"><code>options</code></td>
585
586
587 <td class="type">
588
589
590<span class="param-type">object</span>
591
592
593
594 </td>
595
596
597 <td class="attributes">
598
599 &lt;optional><br>
600
601
602
603
604
605 </td>
606
607
608
609
610 <td class="description last"><p>(optional) options to configure dynamic view with</p>
611 <h6>Properties</h6>
612
613
614<table class="params">
615 <thead>
616 <tr>
617
618 <th>Name</th>
619
620
621 <th>Type</th>
622
623
624
625
626
627 <th class="last">Description</th>
628 </tr>
629 </thead>
630
631 <tbody>
632
633
634 <tr>
635
636 <td class="name"><code>persistent</code></td>
637
638
639 <td class="type">
640
641
642<span class="param-type">boolean</span>
643
644
645
646 </td>
647
648
649
650
651
652 <td class="description last"><p>indicates if view is to main internal results array in 'resultdata'</p></td>
653 </tr>
654
655
656
657 <tr>
658
659 <td class="name"><code>sortPriority</code></td>
660
661
662 <td class="type">
663
664
665<span class="param-type">string</span>
666
667
668
669 </td>
670
671
672
673
674
675 <td class="description last"><p>'passive' (sorts performed on call to data) or 'active' (after updates)</p></td>
676 </tr>
677
678
679
680 <tr>
681
682 <td class="name"><code>minRebuildInterval</code></td>
683
684
685 <td class="type">
686
687
688<span class="param-type">number</span>
689
690
691
692 </td>
693
694
695
696
697
698 <td class="description last"><p>minimum rebuild interval (need clarification to docs here)</p></td>
699 </tr>
700
701
702 </tbody>
703</table>
704
705 </td>
706 </tr>
707
708
709 </tbody>
710</table>
711
712
713
714
715
716
717<dl class="details">
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744 <dt class="tag-source">Source:</dt>
745 <dd class="tag-source"><ul class="dummy"><li>
746 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line4530">line 4530</a>
747 </li></ul></dd>
748
749
750
751
752
753
754
755</dl>
756
757
758
759
760
761
762
763
764
765
766
767
768
769<h5>Returns:</h5>
770
771
772<div class="param-desc">
773 <p>reference to the dynamic view added</p>
774</div>
775
776
777
778<dl>
779 <dt>
780 Type
781 </dt>
782 <dd>
783
784<span class="param-type"><a href="DynamicView.html">DynamicView</a></span>
785
786
787 </dd>
788</dl>
789
790
791
792
793
794
795
796
797
798
799 <h4 class="name" id="addTransform"><span class="type-signature"></span>addTransform<span class="signature">(name, transform)</span><span class="type-signature"></span></h4>
800
801
802
803
804
805<div class="description">
806 <p>Adds a named collection transform to the collection</p>
807</div>
808
809
810
811
812
813
814
815
816
817 <h5>Parameters:</h5>
818
819
820<table class="params">
821 <thead>
822 <tr>
823
824 <th>Name</th>
825
826
827 <th>Type</th>
828
829
830
831
832
833 <th class="last">Description</th>
834 </tr>
835 </thead>
836
837 <tbody>
838
839
840 <tr>
841
842 <td class="name"><code>name</code></td>
843
844
845 <td class="type">
846
847
848<span class="param-type">string</span>
849
850
851
852 </td>
853
854
855
856
857
858 <td class="description last"><p>name to associate with transform</p></td>
859 </tr>
860
861
862
863 <tr>
864
865 <td class="name"><code>transform</code></td>
866
867
868 <td class="type">
869
870
871<span class="param-type">array</span>
872
873
874
875 </td>
876
877
878
879
880
881 <td class="description last"><p>an array of transformation 'step' objects to save into the collection</p></td>
882 </tr>
883
884
885 </tbody>
886</table>
887
888
889
890
891
892
893<dl class="details">
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920 <dt class="tag-source">Source:</dt>
921 <dd class="tag-source"><ul class="dummy"><li>
922 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line4271">line 4271</a>
923 </li></ul></dd>
924
925
926
927
928
929
930
931</dl>
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953 <h4 class="name" id="avg"><span class="type-signature"></span>avg<span class="signature">(field)</span><span class="type-signature"> &rarr; {number}</span></h4>
954
955
956
957
958
959<div class="description">
960 <p>Calculates the average numerical value of a property</p>
961</div>
962
963
964
965
966
967
968
969
970
971 <h5>Parameters:</h5>
972
973
974<table class="params">
975 <thead>
976 <tr>
977
978 <th>Name</th>
979
980
981 <th>Type</th>
982
983
984
985
986
987 <th class="last">Description</th>
988 </tr>
989 </thead>
990
991 <tbody>
992
993
994 <tr>
995
996 <td class="name"><code>field</code></td>
997
998
999 <td class="type">
1000
1001
1002<span class="param-type">string</span>
1003
1004
1005
1006 </td>
1007
1008
1009
1010
1011
1012 <td class="description last"><p>name of property in docs to average</p></td>
1013 </tr>
1014
1015
1016 </tbody>
1017</table>
1018
1019
1020
1021
1022
1023
1024<dl class="details">
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051 <dt class="tag-source">Source:</dt>
1052 <dd class="tag-source"><ul class="dummy"><li>
1053 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line5746">line 5746</a>
1054 </li></ul></dd>
1055
1056
1057
1058
1059
1060
1061
1062</dl>
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076<h5>Returns:</h5>
1077
1078
1079<div class="param-desc">
1080 <p>average of property in all docs in the collection</p>
1081</div>
1082
1083
1084
1085<dl>
1086 <dt>
1087 Type
1088 </dt>
1089 <dd>
1090
1091<span class="param-type">number</span>
1092
1093
1094 </dd>
1095</dl>
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106 <h4 class="name" id="by"><span class="type-signature"></span>by<span class="signature">(field, value)</span><span class="type-signature"> &rarr; {object}</span></h4>
1107
1108
1109
1110
1111
1112<div class="description">
1113 <p>Retrieve doc by Unique index</p>
1114</div>
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124 <h5>Parameters:</h5>
1125
1126
1127<table class="params">
1128 <thead>
1129 <tr>
1130
1131 <th>Name</th>
1132
1133
1134 <th>Type</th>
1135
1136
1137
1138
1139
1140 <th class="last">Description</th>
1141 </tr>
1142 </thead>
1143
1144 <tbody>
1145
1146
1147 <tr>
1148
1149 <td class="name"><code>field</code></td>
1150
1151
1152 <td class="type">
1153
1154
1155<span class="param-type">string</span>
1156
1157
1158
1159 </td>
1160
1161
1162
1163
1164
1165 <td class="description last"><p>name of uniquely indexed property to use when doing lookup</p></td>
1166 </tr>
1167
1168
1169
1170 <tr>
1171
1172 <td class="name"><code>value</code></td>
1173
1174
1175 <td class="type">
1176
1177
1178<span class="param-type">value</span>
1179
1180
1181
1182 </td>
1183
1184
1185
1186
1187
1188 <td class="description last"><p>unique value to search for</p></td>
1189 </tr>
1190
1191
1192 </tbody>
1193</table>
1194
1195
1196
1197
1198
1199
1200<dl class="details">
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227 <dt class="tag-source">Source:</dt>
1228 <dd class="tag-source"><ul class="dummy"><li>
1229 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line5372">line 5372</a>
1230 </li></ul></dd>
1231
1232
1233
1234
1235
1236
1237
1238</dl>
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252<h5>Returns:</h5>
1253
1254
1255<div class="param-desc">
1256 <p>document matching the value passed</p>
1257</div>
1258
1259
1260
1261<dl>
1262 <dt>
1263 Type
1264 </dt>
1265 <dd>
1266
1267<span class="param-type">object</span>
1268
1269
1270 </dd>
1271</dl>
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282 <h4 class="name" id="chain"><span class="type-signature"></span>chain<span class="signature">(transform, parameters)</span><span class="type-signature"> &rarr; {<a href="Resultset.html">Resultset</a>}</span></h4>
1283
1284
1285
1286
1287
1288<div class="description">
1289 <p>Chain method, used for beginning a series of chained find() and/or view() operations
1290on a collection.</p>
1291</div>
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301 <h5>Parameters:</h5>
1302
1303
1304<table class="params">
1305 <thead>
1306 <tr>
1307
1308 <th>Name</th>
1309
1310
1311 <th>Type</th>
1312
1313
1314
1315
1316
1317 <th class="last">Description</th>
1318 </tr>
1319 </thead>
1320
1321 <tbody>
1322
1323
1324 <tr>
1325
1326 <td class="name"><code>transform</code></td>
1327
1328
1329 <td class="type">
1330
1331
1332<span class="param-type">array</span>
1333
1334
1335
1336 </td>
1337
1338
1339
1340
1341
1342 <td class="description last"><p>Ordered array of transform step objects similar to chain</p></td>
1343 </tr>
1344
1345
1346
1347 <tr>
1348
1349 <td class="name"><code>parameters</code></td>
1350
1351
1352 <td class="type">
1353
1354
1355<span class="param-type">object</span>
1356
1357
1358
1359 </td>
1360
1361
1362
1363
1364
1365 <td class="description last"><p>Object containing properties representing parameters to substitute</p></td>
1366 </tr>
1367
1368
1369 </tbody>
1370</table>
1371
1372
1373
1374
1375
1376
1377<dl class="details">
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404 <dt class="tag-source">Source:</dt>
1405 <dd class="tag-source"><ul class="dummy"><li>
1406 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line5424">line 5424</a>
1407 </li></ul></dd>
1408
1409
1410
1411
1412
1413
1414
1415</dl>
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429<h5>Returns:</h5>
1430
1431
1432<div class="param-desc">
1433 <p>(this) resultset, or data array if any map or join functions where called</p>
1434</div>
1435
1436
1437
1438<dl>
1439 <dt>
1440 Type
1441 </dt>
1442 <dd>
1443
1444<span class="param-type"><a href="Resultset.html">Resultset</a></span>
1445
1446
1447 </dd>
1448</dl>
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459 <h4 class="name" id="clear"><span class="type-signature"></span>clear<span class="signature">()</span><span class="type-signature"></span></h4>
1460
1461
1462
1463
1464
1465<div class="description">
1466 <p>Empties the collection.</p>
1467</div>
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481<dl class="details">
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508 <dt class="tag-source">Source:</dt>
1509 <dd class="tag-source"><ul class="dummy"><li>
1510 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line4674">line 4674</a>
1511 </li></ul></dd>
1512
1513
1514
1515
1516
1517
1518
1519</dl>
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541 <h4 class="name" id="commitStage"><span class="type-signature"></span>commitStage<span class="signature">(stageName, message)</span><span class="type-signature"></span></h4>
1542
1543
1544
1545
1546
1547<div class="description">
1548 <p>(Staging API) re-attach all objects to the original collection, so indexes and views can be rebuilt
1549then create a message to be inserted in the commitlog</p>
1550</div>
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560 <h5>Parameters:</h5>
1561
1562
1563<table class="params">
1564 <thead>
1565 <tr>
1566
1567 <th>Name</th>
1568
1569
1570 <th>Type</th>
1571
1572
1573
1574
1575
1576 <th class="last">Description</th>
1577 </tr>
1578 </thead>
1579
1580 <tbody>
1581
1582
1583 <tr>
1584
1585 <td class="name"><code>stageName</code></td>
1586
1587
1588 <td class="type">
1589
1590
1591<span class="param-type">string</span>
1592
1593
1594
1595 </td>
1596
1597
1598
1599
1600
1601 <td class="description last"><p>name of stage</p></td>
1602 </tr>
1603
1604
1605
1606 <tr>
1607
1608 <td class="name"><code>message</code></td>
1609
1610
1611 <td class="type">
1612
1613
1614<span class="param-type">string</span>
1615
1616
1617
1618 </td>
1619
1620
1621
1622
1623
1624 <td class="description last"></td>
1625 </tr>
1626
1627
1628 </tbody>
1629</table>
1630
1631
1632
1633
1634
1635
1636<dl class="details">
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663 <dt class="tag-source">Source:</dt>
1664 <dd class="tag-source"><ul class="dummy"><li>
1665 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line5625">line 5625</a>
1666 </li></ul></dd>
1667
1668
1669
1670
1671
1672
1673
1674</dl>
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696 <h4 class="name" id="configureOptions"><span class="type-signature"></span>configureOptions<span class="signature">()</span><span class="type-signature"></span></h4>
1697
1698
1699
1700
1701
1702<div class="description">
1703 <p>Will allow reconfiguring certain collection options.</p>
1704</div>
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714 <h5>Parameters:</h5>
1715
1716
1717<table class="params">
1718 <thead>
1719 <tr>
1720
1721 <th>Name</th>
1722
1723
1724 <th>Type</th>
1725
1726
1727
1728
1729
1730 <th class="last">Description</th>
1731 </tr>
1732 </thead>
1733
1734 <tbody>
1735
1736
1737 <tr>
1738
1739 <td class="name"><code>options.adaptiveBinaryIndices</code></td>
1740
1741
1742 <td class="type">
1743
1744
1745<span class="param-type">boolean</span>
1746
1747
1748
1749 </td>
1750
1751
1752
1753
1754
1755 <td class="description last"><p>collection indices will be actively rebuilt rather than lazily</p></td>
1756 </tr>
1757
1758
1759 </tbody>
1760</table>
1761
1762
1763
1764
1765
1766
1767<dl class="details">
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794 <dt class="tag-source">Source:</dt>
1795 <dd class="tag-source"><ul class="dummy"><li>
1796 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line4370">line 4370</a>
1797 </li></ul></dd>
1798
1799
1800
1801
1802
1803
1804
1805</dl>
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827 <h4 class="name" id="count"><span class="type-signature"></span>count<span class="signature">(query<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {number}</span></h4>
1828
1829
1830
1831
1832
1833<div class="description">
1834 <p>Quickly determine number of documents in collection (or query)</p>
1835</div>
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845 <h5>Parameters:</h5>
1846
1847
1848<table class="params">
1849 <thead>
1850 <tr>
1851
1852 <th>Name</th>
1853
1854
1855 <th>Type</th>
1856
1857
1858 <th>Attributes</th>
1859
1860
1861
1862
1863 <th class="last">Description</th>
1864 </tr>
1865 </thead>
1866
1867 <tbody>
1868
1869
1870 <tr>
1871
1872 <td class="name"><code>query</code></td>
1873
1874
1875 <td class="type">
1876
1877
1878<span class="param-type">object</span>
1879
1880
1881
1882 </td>
1883
1884
1885 <td class="attributes">
1886
1887 &lt;optional><br>
1888
1889
1890
1891
1892
1893 </td>
1894
1895
1896
1897
1898 <td class="description last"><p>(optional) query object to count results of</p></td>
1899 </tr>
1900
1901
1902 </tbody>
1903</table>
1904
1905
1906
1907
1908
1909
1910<dl class="details">
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937 <dt class="tag-source">Source:</dt>
1938 <dd class="tag-source"><ul class="dummy"><li>
1939 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line4489">line 4489</a>
1940 </li></ul></dd>
1941
1942
1943
1944
1945
1946
1947
1948</dl>
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962<h5>Returns:</h5>
1963
1964
1965<div class="param-desc">
1966 <p>number of documents in the collection</p>
1967</div>
1968
1969
1970
1971<dl>
1972 <dt>
1973 Type
1974 </dt>
1975 <dd>
1976
1977<span class="param-type">number</span>
1978
1979
1980 </dd>
1981</dl>
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992 <h4 class="name" id="ensureIndex"><span class="type-signature"></span>ensureIndex<span class="signature">(property, force<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
1993
1994
1995
1996
1997
1998<div class="description">
1999 <p>Ensure binary index on a certain field</p>
2000</div>
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010 <h5>Parameters:</h5>
2011
2012
2013<table class="params">
2014 <thead>
2015 <tr>
2016
2017 <th>Name</th>
2018
2019
2020 <th>Type</th>
2021
2022
2023 <th>Attributes</th>
2024
2025
2026
2027
2028 <th class="last">Description</th>
2029 </tr>
2030 </thead>
2031
2032 <tbody>
2033
2034
2035 <tr>
2036
2037 <td class="name"><code>property</code></td>
2038
2039
2040 <td class="type">
2041
2042
2043<span class="param-type">string</span>
2044
2045
2046
2047 </td>
2048
2049
2050 <td class="attributes">
2051
2052
2053
2054
2055
2056 </td>
2057
2058
2059
2060
2061 <td class="description last"><p>name of property to create binary index on</p></td>
2062 </tr>
2063
2064
2065
2066 <tr>
2067
2068 <td class="name"><code>force</code></td>
2069
2070
2071 <td class="type">
2072
2073
2074<span class="param-type">boolean</span>
2075
2076
2077
2078 </td>
2079
2080
2081 <td class="attributes">
2082
2083 &lt;optional><br>
2084
2085
2086
2087
2088
2089 </td>
2090
2091
2092
2093
2094 <td class="description last"><p>(Optional) flag indicating whether to construct index immediately</p></td>
2095 </tr>
2096
2097
2098 </tbody>
2099</table>
2100
2101
2102
2103
2104
2105
2106<dl class="details">
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133 <dt class="tag-source">Source:</dt>
2134 <dd class="tag-source"><ul class="dummy"><li>
2135 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line4389">line 4389</a>
2136 </li></ul></dd>
2137
2138
2139
2140
2141
2142
2143
2144</dl>
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166 <h4 class="name" id="eqJoin"><span class="type-signature"></span>eqJoin<span class="signature">(joinData, leftJoinProp, rightJoinProp, mapFun<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {<a href="Resultset.html">Resultset</a>}</span></h4>
2167
2168
2169
2170
2171
2172<div class="description">
2173 <p>Join two collections on specified properties</p>
2174</div>
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184 <h5>Parameters:</h5>
2185
2186
2187<table class="params">
2188 <thead>
2189 <tr>
2190
2191 <th>Name</th>
2192
2193
2194 <th>Type</th>
2195
2196
2197 <th>Attributes</th>
2198
2199
2200
2201
2202 <th class="last">Description</th>
2203 </tr>
2204 </thead>
2205
2206 <tbody>
2207
2208
2209 <tr>
2210
2211 <td class="name"><code>joinData</code></td>
2212
2213
2214 <td class="type">
2215
2216
2217<span class="param-type">array</span>
2218
2219
2220
2221 </td>
2222
2223
2224 <td class="attributes">
2225
2226
2227
2228
2229
2230 </td>
2231
2232
2233
2234
2235 <td class="description last"><p>array of documents to 'join' to this collection</p></td>
2236 </tr>
2237
2238
2239
2240 <tr>
2241
2242 <td class="name"><code>leftJoinProp</code></td>
2243
2244
2245 <td class="type">
2246
2247
2248<span class="param-type">string</span>
2249
2250
2251
2252 </td>
2253
2254
2255 <td class="attributes">
2256
2257
2258
2259
2260
2261 </td>
2262
2263
2264
2265
2266 <td class="description last"><p>property name in collection</p></td>
2267 </tr>
2268
2269
2270
2271 <tr>
2272
2273 <td class="name"><code>rightJoinProp</code></td>
2274
2275
2276 <td class="type">
2277
2278
2279<span class="param-type">string</span>
2280
2281
2282
2283 </td>
2284
2285
2286 <td class="attributes">
2287
2288
2289
2290
2291
2292 </td>
2293
2294
2295
2296
2297 <td class="description last"><p>property name in joinData</p></td>
2298 </tr>
2299
2300
2301
2302 <tr>
2303
2304 <td class="name"><code>mapFun</code></td>
2305
2306
2307 <td class="type">
2308
2309
2310<span class="param-type">function</span>
2311
2312
2313
2314 </td>
2315
2316
2317 <td class="attributes">
2318
2319 &lt;optional><br>
2320
2321
2322
2323
2324
2325 </td>
2326
2327
2328
2329
2330 <td class="description last"><p>(Optional) map function to use</p></td>
2331 </tr>
2332
2333
2334 </tbody>
2335</table>
2336
2337
2338
2339
2340
2341
2342<dl class="details">
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369 <dt class="tag-source">Source:</dt>
2370 <dd class="tag-source"><ul class="dummy"><li>
2371 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line5581">line 5581</a>
2372 </li></ul></dd>
2373
2374
2375
2376
2377
2378
2379
2380</dl>
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394<h5>Returns:</h5>
2395
2396
2397<div class="param-desc">
2398 <p>Result of the mapping operation</p>
2399</div>
2400
2401
2402
2403<dl>
2404 <dt>
2405 Type
2406 </dt>
2407 <dd>
2408
2409<span class="param-type"><a href="Resultset.html">Resultset</a></span>
2410
2411
2412 </dd>
2413</dl>
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424 <h4 class="name" id="extract"><span class="type-signature"></span>extract<span class="signature">()</span><span class="type-signature"></span></h4>
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442<dl class="details">
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469 <dt class="tag-source">Source:</dt>
2470 <dd class="tag-source"><ul class="dummy"><li>
2471 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line5649">line 5649</a>
2472 </li></ul></dd>
2473
2474
2475
2476
2477
2478
2479
2480</dl>
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502 <h4 class="name" id="extractNumerical"><span class="type-signature"></span>extractNumerical<span class="signature">()</span><span class="type-signature"></span></h4>
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520<dl class="details">
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547 <dt class="tag-source">Source:</dt>
2548 <dd class="tag-source"><ul class="dummy"><li>
2549 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line5733">line 5733</a>
2550 </li></ul></dd>
2551
2552
2553
2554
2555
2556
2557
2558</dl>
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580 <h4 class="name" id="find"><span class="type-signature"></span>find<span class="signature">(query)</span><span class="type-signature"> &rarr; {array}</span></h4>
2581
2582
2583
2584
2585
2586<div class="description">
2587 <p>Find method, api is similar to mongodb.
2588for more complex queries use <a href="Collection.html#chain">chain()</a> or <a href="Collection.html#where">where()</a>.</p>
2589</div>
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599 <h5>Parameters:</h5>
2600
2601
2602<table class="params">
2603 <thead>
2604 <tr>
2605
2606 <th>Name</th>
2607
2608
2609 <th>Type</th>
2610
2611
2612
2613
2614
2615 <th class="last">Description</th>
2616 </tr>
2617 </thead>
2618
2619 <tbody>
2620
2621
2622 <tr>
2623
2624 <td class="name"><code>query</code></td>
2625
2626
2627 <td class="type">
2628
2629
2630<span class="param-type">object</span>
2631
2632
2633
2634 </td>
2635
2636
2637
2638
2639
2640 <td class="description last"><p>'mongo-like' query object</p></td>
2641 </tr>
2642
2643
2644 </tbody>
2645</table>
2646
2647
2648
2649
2650
2651
2652<dl class="details">
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679 <dt class="tag-source">Source:</dt>
2680 <dd class="tag-source"><ul class="dummy"><li>
2681 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line5442">line 5442</a>
2682 </li></ul></dd>
2683
2684
2685
2686
2687
2688
2689
2690</dl>
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704<h5>Returns:</h5>
2705
2706
2707<div class="param-desc">
2708 <p>Array of matching documents</p>
2709</div>
2710
2711
2712
2713<dl>
2714 <dt>
2715 Type
2716 </dt>
2717 <dd>
2718
2719<span class="param-type">array</span>
2720
2721
2722 </dd>
2723</dl>
2724
2725
2726
2727
2728 <h5>Example</h5>
2729
2730 <pre class="prettyprint"><code><a href="tutorial-Query Examples.html">Query Examples</a></code></pre>
2731
2732
2733
2734
2735
2736
2737
2738
2739 <h4 class="name" id="findAndRemove"><span class="type-signature"></span>findAndRemove<span class="signature">(filterObject)</span><span class="type-signature"></span></h4>
2740
2741
2742
2743
2744
2745<div class="description">
2746 <p>Applies a 'mongo-like' find query object removes all documents which match that filter.</p>
2747</div>
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757 <h5>Parameters:</h5>
2758
2759
2760<table class="params">
2761 <thead>
2762 <tr>
2763
2764 <th>Name</th>
2765
2766
2767 <th>Type</th>
2768
2769
2770
2771
2772
2773 <th class="last">Description</th>
2774 </tr>
2775 </thead>
2776
2777 <tbody>
2778
2779
2780 <tr>
2781
2782 <td class="name"><code>filterObject</code></td>
2783
2784
2785 <td class="type">
2786
2787
2788<span class="param-type">object</span>
2789
2790
2791
2792 </td>
2793
2794
2795
2796
2797
2798 <td class="description last"><p>'mongo-like' query object</p></td>
2799 </tr>
2800
2801
2802 </tbody>
2803</table>
2804
2805
2806
2807
2808
2809
2810<dl class="details">
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837 <dt class="tag-source">Source:</dt>
2838 <dd class="tag-source"><ul class="dummy"><li>
2839 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line4589">line 4589</a>
2840 </li></ul></dd>
2841
2842
2843
2844
2845
2846
2847
2848</dl>
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870 <h4 class="name" id="findAndUpdate"><span class="type-signature"></span>findAndUpdate<span class="signature">(filterObject, updateFunction)</span><span class="type-signature"></span></h4>
2871
2872
2873
2874
2875
2876<div class="description">
2877 <p>Applies a 'mongo-like' find query object and passes all results to an update function.
2878For filter function querying you should migrate to <a href="Collection.html#updateWhere">updateWhere()</a>.</p>
2879</div>
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889 <h5>Parameters:</h5>
2890
2891
2892<table class="params">
2893 <thead>
2894 <tr>
2895
2896 <th>Name</th>
2897
2898
2899 <th>Type</th>
2900
2901
2902
2903
2904
2905 <th class="last">Description</th>
2906 </tr>
2907 </thead>
2908
2909 <tbody>
2910
2911
2912 <tr>
2913
2914 <td class="name"><code>filterObject</code></td>
2915
2916
2917 <td class="type">
2918
2919
2920<span class="param-type">object</span>
2921|
2922
2923<span class="param-type">function</span>
2924
2925
2926
2927 </td>
2928
2929
2930
2931
2932
2933 <td class="description last"><p>'mongo-like' query object (or deprecated filterFunction mode)</p></td>
2934 </tr>
2935
2936
2937
2938 <tr>
2939
2940 <td class="name"><code>updateFunction</code></td>
2941
2942
2943 <td class="type">
2944
2945
2946<span class="param-type">function</span>
2947
2948
2949
2950 </td>
2951
2952
2953
2954
2955
2956 <td class="description last"><p>update function to run against filtered documents</p></td>
2957 </tr>
2958
2959
2960 </tbody>
2961</table>
2962
2963
2964
2965
2966
2967
2968<dl class="details">
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995 <dt class="tag-source">Source:</dt>
2996 <dd class="tag-source"><ul class="dummy"><li>
2997 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line4574">line 4574</a>
2998 </li></ul></dd>
2999
3000
3001
3002
3003
3004
3005
3006</dl>
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028 <h4 class="name" id="findOne"><span class="type-signature"></span>findOne<span class="signature">(query)</span><span class="type-signature"> &rarr; {object|null}</span></h4>
3029
3030
3031
3032
3033
3034<div class="description">
3035 <p>Find one object by index property, by property equal to value</p>
3036</div>
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046 <h5>Parameters:</h5>
3047
3048
3049<table class="params">
3050 <thead>
3051 <tr>
3052
3053 <th>Name</th>
3054
3055
3056 <th>Type</th>
3057
3058
3059
3060
3061
3062 <th class="last">Description</th>
3063 </tr>
3064 </thead>
3065
3066 <tbody>
3067
3068
3069 <tr>
3070
3071 <td class="name"><code>query</code></td>
3072
3073
3074 <td class="type">
3075
3076
3077<span class="param-type">object</span>
3078
3079
3080
3081 </td>
3082
3083
3084
3085
3086
3087 <td class="description last"><p>query object used to perform search with</p></td>
3088 </tr>
3089
3090
3091 </tbody>
3092</table>
3093
3094
3095
3096
3097
3098
3099<dl class="details">
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126 <dt class="tag-source">Source:</dt>
3127 <dd class="tag-source"><ul class="dummy"><li>
3128 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line5395">line 5395</a>
3129 </li></ul></dd>
3130
3131
3132
3133
3134
3135
3136
3137</dl>
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151<h5>Returns:</h5>
3152
3153
3154<div class="param-desc">
3155 <p>First matching document, or null if none</p>
3156</div>
3157
3158
3159
3160<dl>
3161 <dt>
3162 Type
3163 </dt>
3164 <dd>
3165
3166<span class="param-type">object</span>
3167|
3168
3169<span class="param-type">null</span>
3170
3171
3172 </dd>
3173</dl>
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184 <h4 class="name" id="get"><span class="type-signature"></span>get<span class="signature">(id, returnPosition)</span><span class="type-signature"> &rarr; {object|array|null}</span></h4>
3185
3186
3187
3188
3189
3190<div class="description">
3191 <p>Get by Id - faster than other methods because of the searching algorithm</p>
3192</div>
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202 <h5>Parameters:</h5>
3203
3204
3205<table class="params">
3206 <thead>
3207 <tr>
3208
3209 <th>Name</th>
3210
3211
3212 <th>Type</th>
3213
3214
3215
3216
3217
3218 <th class="last">Description</th>
3219 </tr>
3220 </thead>
3221
3222 <tbody>
3223
3224
3225 <tr>
3226
3227 <td class="name"><code>id</code></td>
3228
3229
3230 <td class="type">
3231
3232
3233<span class="param-type">int</span>
3234
3235
3236
3237 </td>
3238
3239
3240
3241
3242
3243 <td class="description last"><p>$loki id of document you want to retrieve</p></td>
3244 </tr>
3245
3246
3247
3248 <tr>
3249
3250 <td class="name"><code>returnPosition</code></td>
3251
3252
3253 <td class="type">
3254
3255
3256<span class="param-type">boolean</span>
3257
3258
3259
3260 </td>
3261
3262
3263
3264
3265
3266 <td class="description last"><p>if 'true' we will return [object, position]</p></td>
3267 </tr>
3268
3269
3270 </tbody>
3271</table>
3272
3273
3274
3275
3276
3277
3278<dl class="details">
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305 <dt class="tag-source">Source:</dt>
3306 <dd class="tag-source"><ul class="dummy"><li>
3307 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line4974">line 4974</a>
3308 </li></ul></dd>
3309
3310
3311
3312
3313
3314
3315
3316</dl>
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330<h5>Returns:</h5>
3331
3332
3333<div class="param-desc">
3334 <p>Object reference if document was found, null if not,
3335 or an array if 'returnPosition' was passed.</p>
3336</div>
3337
3338
3339
3340<dl>
3341 <dt>
3342 Type
3343 </dt>
3344 <dd>
3345
3346<span class="param-type">object</span>
3347|
3348
3349<span class="param-type">array</span>
3350|
3351
3352<span class="param-type">null</span>
3353
3354
3355 </dd>
3356</dl>
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367 <h4 class="name" id="getDynamicView"><span class="type-signature"></span>getDynamicView<span class="signature">(name)</span><span class="type-signature"> &rarr; {<a href="DynamicView.html">DynamicView</a>}</span></h4>
3368
3369
3370
3371
3372
3373<div class="description">
3374 <p>Look up dynamic view reference from within the collection</p>
3375</div>
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385 <h5>Parameters:</h5>
3386
3387
3388<table class="params">
3389 <thead>
3390 <tr>
3391
3392 <th>Name</th>
3393
3394
3395 <th>Type</th>
3396
3397
3398
3399
3400
3401 <th class="last">Description</th>
3402 </tr>
3403 </thead>
3404
3405 <tbody>
3406
3407
3408 <tr>
3409
3410 <td class="name"><code>name</code></td>
3411
3412
3413 <td class="type">
3414
3415
3416<span class="param-type">string</span>
3417
3418
3419
3420 </td>
3421
3422
3423
3424
3425
3426 <td class="description last"><p>name of dynamic view to retrieve reference of</p></td>
3427 </tr>
3428
3429
3430 </tbody>
3431</table>
3432
3433
3434
3435
3436
3437
3438<dl class="details">
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465 <dt class="tag-source">Source:</dt>
3466 <dd class="tag-source"><ul class="dummy"><li>
3467 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line4556">line 4556</a>
3468 </li></ul></dd>
3469
3470
3471
3472
3473
3474
3475
3476</dl>
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490<h5>Returns:</h5>
3491
3492
3493<div class="param-desc">
3494 <p>A reference to the dynamic view with that name</p>
3495</div>
3496
3497
3498
3499<dl>
3500 <dt>
3501 Type
3502 </dt>
3503 <dd>
3504
3505<span class="param-type"><a href="DynamicView.html">DynamicView</a></span>
3506
3507
3508 </dd>
3509</dl>
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520 <h4 class="name" id="getStage"><span class="type-signature"></span>getStage<span class="signature">()</span><span class="type-signature"></span></h4>
3521
3522
3523
3524
3525
3526<div class="description">
3527 <p>(Staging API) create a stage and/or retrieve it</p>
3528</div>
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542<dl class="details">
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569 <dt class="tag-source">Source:</dt>
3570 <dd class="tag-source"><ul class="dummy"><li>
3571 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line5597">line 5597</a>
3572 </li></ul></dd>
3573
3574
3575
3576
3577
3578
3579
3580</dl>
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602 <h4 class="name" id="insert"><span class="type-signature"></span>insert<span class="signature">(doc)</span><span class="type-signature"> &rarr; {object|array}</span></h4>
3603
3604
3605
3606
3607
3608<div class="description">
3609 <p>Adds object(s) to collection, ensure object(s) have meta properties, clone it if necessary, etc.</p>
3610</div>
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620 <h5>Parameters:</h5>
3621
3622
3623<table class="params">
3624 <thead>
3625 <tr>
3626
3627 <th>Name</th>
3628
3629
3630 <th>Type</th>
3631
3632
3633
3634
3635
3636 <th class="last">Description</th>
3637 </tr>
3638 </thead>
3639
3640 <tbody>
3641
3642
3643 <tr>
3644
3645 <td class="name"><code>doc</code></td>
3646
3647
3648 <td class="type">
3649
3650
3651<span class="param-type">object</span>
3652|
3653
3654<span class="param-type">array</span>
3655
3656
3657
3658 </td>
3659
3660
3661
3662
3663
3664 <td class="description last"><p>the document (or array of documents) to be inserted</p></td>
3665 </tr>
3666
3667
3668 </tbody>
3669</table>
3670
3671
3672
3673
3674
3675
3676<dl class="details">
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703 <dt class="tag-source">Source:</dt>
3704 <dd class="tag-source"><ul class="dummy"><li>
3705 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line4599">line 4599</a>
3706 </li></ul></dd>
3707
3708
3709
3710
3711
3712
3713
3714</dl>
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728<h5>Returns:</h5>
3729
3730
3731<div class="param-desc">
3732 <p>document or documents inserted</p>
3733</div>
3734
3735
3736
3737<dl>
3738 <dt>
3739 Type
3740 </dt>
3741 <dd>
3742
3743<span class="param-type">object</span>
3744|
3745
3746<span class="param-type">array</span>
3747
3748
3749 </dd>
3750</dl>
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761 <h4 class="name" id="insertOne"><span class="type-signature"></span>insertOne<span class="signature">(doc, bulkInsert)</span><span class="type-signature"> &rarr; {object}</span></h4>
3762
3763
3764
3765
3766
3767<div class="description">
3768 <p>Adds a single object, ensures it has meta properties, clone it if necessary, etc.</p>
3769</div>
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779 <h5>Parameters:</h5>
3780
3781
3782<table class="params">
3783 <thead>
3784 <tr>
3785
3786 <th>Name</th>
3787
3788
3789 <th>Type</th>
3790
3791
3792
3793
3794
3795 <th class="last">Description</th>
3796 </tr>
3797 </thead>
3798
3799 <tbody>
3800
3801
3802 <tr>
3803
3804 <td class="name"><code>doc</code></td>
3805
3806
3807 <td class="type">
3808
3809
3810<span class="param-type">object</span>
3811
3812
3813
3814 </td>
3815
3816
3817
3818
3819
3820 <td class="description last"><p>the document to be inserted</p></td>
3821 </tr>
3822
3823
3824
3825 <tr>
3826
3827 <td class="name"><code>bulkInsert</code></td>
3828
3829
3830 <td class="type">
3831
3832
3833<span class="param-type">boolean</span>
3834
3835
3836
3837 </td>
3838
3839
3840
3841
3842
3843 <td class="description last"><p>quiet pre-insert and insert event emits</p></td>
3844 </tr>
3845
3846
3847 </tbody>
3848</table>
3849
3850
3851
3852
3853
3854
3855<dl class="details">
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882 <dt class="tag-source">Source:</dt>
3883 <dd class="tag-source"><ul class="dummy"><li>
3884 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line4627">line 4627</a>
3885 </li></ul></dd>
3886
3887
3888
3889
3890
3891
3892
3893</dl>
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907<h5>Returns:</h5>
3908
3909
3910<div class="param-desc">
3911 <p>document or 'undefined' if there was a problem inserting it</p>
3912</div>
3913
3914
3915
3916<dl>
3917 <dt>
3918 Type
3919 </dt>
3920 <dd>
3921
3922<span class="param-type">object</span>
3923
3924
3925 </dd>
3926</dl>
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937 <h4 class="name" id="mapReduce"><span class="type-signature"></span>mapReduce<span class="signature">(mapFunction, reduceFunction)</span><span class="type-signature"> &rarr; {data}</span></h4>
3938
3939
3940
3941
3942
3943<div class="description">
3944 <p>Map Reduce operation</p>
3945</div>
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955 <h5>Parameters:</h5>
3956
3957
3958<table class="params">
3959 <thead>
3960 <tr>
3961
3962 <th>Name</th>
3963
3964
3965 <th>Type</th>
3966
3967
3968
3969
3970
3971 <th class="last">Description</th>
3972 </tr>
3973 </thead>
3974
3975 <tbody>
3976
3977
3978 <tr>
3979
3980 <td class="name"><code>mapFunction</code></td>
3981
3982
3983 <td class="type">
3984
3985
3986<span class="param-type">function</span>
3987
3988
3989
3990 </td>
3991
3992
3993
3994
3995
3996 <td class="description last"><p>function to use as map function</p></td>
3997 </tr>
3998
3999
4000
4001 <tr>
4002
4003 <td class="name"><code>reduceFunction</code></td>
4004
4005
4006 <td class="type">
4007
4008
4009<span class="param-type">function</span>
4010
4011
4012
4013 </td>
4014
4015
4016
4017
4018
4019 <td class="description last"><p>function to use as reduce function</p></td>
4020 </tr>
4021
4022
4023 </tbody>
4024</table>
4025
4026
4027
4028
4029
4030
4031<dl class="details">
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058 <dt class="tag-source">Source:</dt>
4059 <dd class="tag-source"><ul class="dummy"><li>
4060 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line5563">line 5563</a>
4061 </li></ul></dd>
4062
4063
4064
4065
4066
4067
4068
4069</dl>
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083<h5>Returns:</h5>
4084
4085
4086<div class="param-desc">
4087 <p>The result of your mapReduce operation</p>
4088</div>
4089
4090
4091
4092<dl>
4093 <dt>
4094 Type
4095 </dt>
4096 <dd>
4097
4098<span class="param-type">data</span>
4099
4100
4101 </dd>
4102</dl>
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113 <h4 class="name" id="max"><span class="type-signature"></span>max<span class="signature">()</span><span class="type-signature"></span></h4>
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131<dl class="details">
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158 <dt class="tag-source">Source:</dt>
4159 <dd class="tag-source"><ul class="dummy"><li>
4160 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line5663">line 5663</a>
4161 </li></ul></dd>
4162
4163
4164
4165
4166
4167
4168
4169</dl>
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191 <h4 class="name" id="maxRecord"><span class="type-signature"></span>maxRecord<span class="signature">()</span><span class="type-signature"></span></h4>
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209<dl class="details">
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236 <dt class="tag-source">Source:</dt>
4237 <dd class="tag-source"><ul class="dummy"><li>
4238 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line5677">line 5677</a>
4239 </li></ul></dd>
4240
4241
4242
4243
4244
4245
4246
4247</dl>
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269 <h4 class="name" id="median"><span class="type-signature"></span>median<span class="signature">(field)</span><span class="type-signature"></span></h4>
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283 <h5>Parameters:</h5>
4284
4285
4286<table class="params">
4287 <thead>
4288 <tr>
4289
4290 <th>Name</th>
4291
4292
4293 <th>Type</th>
4294
4295
4296
4297
4298
4299 <th class="last">Description</th>
4300 </tr>
4301 </thead>
4302
4303 <tbody>
4304
4305
4306 <tr>
4307
4308 <td class="name"><code>field</code></td>
4309
4310
4311 <td class="type">
4312
4313
4314<span class="param-type">string</span>
4315
4316
4317
4318 </td>
4319
4320
4321
4322
4323
4324 <td class="description last"><p>property name</p></td>
4325 </tr>
4326
4327
4328 </tbody>
4329</table>
4330
4331
4332
4333
4334
4335
4336<dl class="details">
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363 <dt class="tag-source">Source:</dt>
4364 <dd class="tag-source"><ul class="dummy"><li>
4365 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line5792">line 5792</a>
4366 </li></ul></dd>
4367
4368
4369
4370
4371
4372
4373
4374</dl>
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396 <h4 class="name" id="min"><span class="type-signature"></span>min<span class="signature">()</span><span class="type-signature"></span></h4>
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414<dl class="details">
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441 <dt class="tag-source">Source:</dt>
4442 <dd class="tag-source"><ul class="dummy"><li>
4443 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line5670">line 5670</a>
4444 </li></ul></dd>
4445
4446
4447
4448
4449
4450
4451
4452</dl>
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474 <h4 class="name" id="minRecord"><span class="type-signature"></span>minRecord<span class="signature">()</span><span class="type-signature"></span></h4>
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492<dl class="details">
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519 <dt class="tag-source">Source:</dt>
4520 <dd class="tag-source"><ul class="dummy"><li>
4521 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line5705">line 5705</a>
4522 </li></ul></dd>
4523
4524
4525
4526
4527
4528
4529
4530</dl>
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552 <h4 class="name" id="mode"><span class="type-signature"></span>mode<span class="signature">(field)</span><span class="type-signature"></span></h4>
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566 <h5>Parameters:</h5>
4567
4568
4569<table class="params">
4570 <thead>
4571 <tr>
4572
4573 <th>Name</th>
4574
4575
4576 <th>Type</th>
4577
4578
4579
4580
4581
4582 <th class="last">Description</th>
4583 </tr>
4584 </thead>
4585
4586 <tbody>
4587
4588
4589 <tr>
4590
4591 <td class="name"><code>field</code></td>
4592
4593
4594 <td class="type">
4595
4596
4597<span class="param-type">string</span>
4598
4599
4600
4601 </td>
4602
4603
4604
4605
4606
4607 <td class="description last"></td>
4608 </tr>
4609
4610
4611 </tbody>
4612</table>
4613
4614
4615
4616
4617
4618
4619<dl class="details">
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646 <dt class="tag-source">Source:</dt>
4647 <dd class="tag-source"><ul class="dummy"><li>
4648 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line5763">line 5763</a>
4649 </li></ul></dd>
4650
4651
4652
4653
4654
4655
4656
4657</dl>
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679 <h4 class="name" id="remove"><span class="type-signature"></span>remove<span class="signature">(doc)</span><span class="type-signature"></span></h4>
4680
4681
4682
4683
4684
4685<div class="description">
4686 <p>Remove a document from the collection</p>
4687</div>
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697 <h5>Parameters:</h5>
4698
4699
4700<table class="params">
4701 <thead>
4702 <tr>
4703
4704 <th>Name</th>
4705
4706
4707 <th>Type</th>
4708
4709
4710
4711
4712
4713 <th class="last">Description</th>
4714 </tr>
4715 </thead>
4716
4717 <tbody>
4718
4719
4720 <tr>
4721
4722 <td class="name"><code>doc</code></td>
4723
4724
4725 <td class="type">
4726
4727
4728<span class="param-type">object</span>
4729
4730
4731
4732 </td>
4733
4734
4735
4736
4737
4738 <td class="description last"><p>document to remove from collection</p></td>
4739 </tr>
4740
4741
4742 </tbody>
4743</table>
4744
4745
4746
4747
4748
4749
4750<dl class="details">
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777 <dt class="tag-source">Source:</dt>
4778 <dd class="tag-source"><ul class="dummy"><li>
4779 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line4892">line 4892</a>
4780 </li></ul></dd>
4781
4782
4783
4784
4785
4786
4787
4788</dl>
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810 <h4 class="name" id="removeDynamicView"><span class="type-signature"></span>removeDynamicView<span class="signature">(name)</span><span class="type-signature"></span></h4>
4811
4812
4813
4814
4815
4816<div class="description">
4817 <p>Remove a dynamic view from the collection</p>
4818</div>
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828 <h5>Parameters:</h5>
4829
4830
4831<table class="params">
4832 <thead>
4833 <tr>
4834
4835 <th>Name</th>
4836
4837
4838 <th>Type</th>
4839
4840
4841
4842
4843
4844 <th class="last">Description</th>
4845 </tr>
4846 </thead>
4847
4848 <tbody>
4849
4850
4851 <tr>
4852
4853 <td class="name"><code>name</code></td>
4854
4855
4856 <td class="type">
4857
4858
4859<span class="param-type">string</span>
4860
4861
4862
4863 </td>
4864
4865
4866
4867
4868
4869 <td class="description last"><p>name of dynamic view to remove</p></td>
4870 </tr>
4871
4872
4873 </tbody>
4874</table>
4875
4876
4877
4878
4879
4880
4881<dl class="details">
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908 <dt class="tag-source">Source:</dt>
4909 <dd class="tag-source"><ul class="dummy"><li>
4910 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line4542">line 4542</a>
4911 </li></ul></dd>
4912
4913
4914
4915
4916
4917
4918
4919</dl>
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941 <h4 class="name" id="removeTransform"><span class="type-signature"></span>removeTransform<span class="signature">(name)</span><span class="type-signature"></span></h4>
4942
4943
4944
4945
4946
4947<div class="description">
4948 <p>Removes a named collection transform from the collection</p>
4949</div>
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959 <h5>Parameters:</h5>
4960
4961
4962<table class="params">
4963 <thead>
4964 <tr>
4965
4966 <th>Name</th>
4967
4968
4969 <th>Type</th>
4970
4971
4972
4973
4974
4975 <th class="last">Description</th>
4976 </tr>
4977 </thead>
4978
4979 <tbody>
4980
4981
4982 <tr>
4983
4984 <td class="name"><code>name</code></td>
4985
4986
4987 <td class="type">
4988
4989
4990<span class="param-type">string</span>
4991
4992
4993
4994 </td>
4995
4996
4997
4998
4999
5000 <td class="description last"><p>name of collection transform to remove</p></td>
5001 </tr>
5002
5003
5004 </tbody>
5005</table>
5006
5007
5008
5009
5010
5011
5012<dl class="details">
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039 <dt class="tag-source">Source:</dt>
5040 <dd class="tag-source"><ul class="dummy"><li>
5041 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line4294">line 4294</a>
5042 </li></ul></dd>
5043
5044
5045
5046
5047
5048
5049
5050</dl>
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072 <h4 class="name" id="removeWhere"><span class="type-signature"></span>removeWhere<span class="signature">(query)</span><span class="type-signature"></span></h4>
5073
5074
5075
5076
5077
5078<div class="description">
5079 <p>Remove all documents matching supplied filter function.
5080For 'mongo-like' querying you should migrate to <a href="Collection.html#findAndRemove">findAndRemove()</a>.</p>
5081</div>
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091 <h5>Parameters:</h5>
5092
5093
5094<table class="params">
5095 <thead>
5096 <tr>
5097
5098 <th>Name</th>
5099
5100
5101 <th>Type</th>
5102
5103
5104
5105
5106
5107 <th class="last">Description</th>
5108 </tr>
5109 </thead>
5110
5111 <tbody>
5112
5113
5114 <tr>
5115
5116 <td class="name"><code>query</code></td>
5117
5118
5119 <td class="type">
5120
5121
5122<span class="param-type">function</span>
5123|
5124
5125<span class="param-type">object</span>
5126
5127
5128
5129 </td>
5130
5131
5132
5133
5134
5135 <td class="description last"><p>query object to filter on</p></td>
5136 </tr>
5137
5138
5139 </tbody>
5140</table>
5141
5142
5143
5144
5145
5146
5147<dl class="details">
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174 <dt class="tag-source">Source:</dt>
5175 <dd class="tag-source"><ul class="dummy"><li>
5176 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line4873">line 4873</a>
5177 </li></ul></dd>
5178
5179
5180
5181
5182
5183
5184
5185</dl>
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207 <h4 class="name" id="setTransform"><span class="type-signature"></span>setTransform<span class="signature">(name, transform)</span><span class="type-signature"></span></h4>
5208
5209
5210
5211
5212
5213<div class="description">
5214 <p>Updates a named collection transform to the collection</p>
5215</div>
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225 <h5>Parameters:</h5>
5226
5227
5228<table class="params">
5229 <thead>
5230 <tr>
5231
5232 <th>Name</th>
5233
5234
5235 <th>Type</th>
5236
5237
5238
5239
5240
5241 <th class="last">Description</th>
5242 </tr>
5243 </thead>
5244
5245 <tbody>
5246
5247
5248 <tr>
5249
5250 <td class="name"><code>name</code></td>
5251
5252
5253 <td class="type">
5254
5255
5256<span class="param-type">string</span>
5257
5258
5259
5260 </td>
5261
5262
5263
5264
5265
5266 <td class="description last"><p>name to associate with transform</p></td>
5267 </tr>
5268
5269
5270
5271 <tr>
5272
5273 <td class="name"><code>transform</code></td>
5274
5275
5276 <td class="type">
5277
5278
5279<span class="param-type">object</span>
5280
5281
5282
5283 </td>
5284
5285
5286
5287
5288
5289 <td class="description last"><p>a transformation object to save into collection</p></td>
5290 </tr>
5291
5292
5293 </tbody>
5294</table>
5295
5296
5297
5298
5299
5300
5301<dl class="details">
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328 <dt class="tag-source">Source:</dt>
5329 <dd class="tag-source"><ul class="dummy"><li>
5330 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line4285">line 4285</a>
5331 </li></ul></dd>
5332
5333
5334
5335
5336
5337
5338
5339</dl>
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361 <h4 class="name" id="stage"><span class="type-signature"></span>stage<span class="signature">()</span><span class="type-signature"></span></h4>
5362
5363
5364
5365
5366
5367<div class="description">
5368 <p>(Staging API) create a copy of an object and insert it into a stage</p>
5369</div>
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383<dl class="details">
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410 <dt class="tag-source">Source:</dt>
5411 <dd class="tag-source"><ul class="dummy"><li>
5412 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line5612">line 5612</a>
5413 </li></ul></dd>
5414
5415
5416
5417
5418
5419
5420
5421</dl>
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443 <h4 class="name" id="stdDev"><span class="type-signature"></span>stdDev<span class="signature">(field)</span><span class="type-signature"></span></h4>
5444
5445
5446
5447
5448
5449<div class="description">
5450 <p>Calculate standard deviation of a field</p>
5451</div>
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461 <h5>Parameters:</h5>
5462
5463
5464<table class="params">
5465 <thead>
5466 <tr>
5467
5468 <th>Name</th>
5469
5470
5471 <th>Type</th>
5472
5473
5474
5475
5476
5477 <th class="last">Description</th>
5478 </tr>
5479 </thead>
5480
5481 <tbody>
5482
5483
5484 <tr>
5485
5486 <td class="name"><code>field</code></td>
5487
5488
5489 <td class="type">
5490
5491
5492<span class="param-type">string</span>
5493
5494
5495
5496 </td>
5497
5498
5499
5500
5501
5502 <td class="description last"></td>
5503 </tr>
5504
5505
5506 </tbody>
5507</table>
5508
5509
5510
5511
5512
5513
5514<dl class="details">
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541 <dt class="tag-source">Source:</dt>
5542 <dd class="tag-source"><ul class="dummy"><li>
5543 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line5755">line 5755</a>
5544 </li></ul></dd>
5545
5546
5547
5548
5549
5550
5551
5552</dl>
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574 <h4 class="name" id="update"><span class="type-signature"></span>update<span class="signature">(doc)</span><span class="type-signature"></span></h4>
5575
5576
5577
5578
5579
5580<div class="description">
5581 <p>Updates an object and notifies collection that the document has changed.</p>
5582</div>
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592 <h5>Parameters:</h5>
5593
5594
5595<table class="params">
5596 <thead>
5597 <tr>
5598
5599 <th>Name</th>
5600
5601
5602 <th>Type</th>
5603
5604
5605
5606
5607
5608 <th class="last">Description</th>
5609 </tr>
5610 </thead>
5611
5612 <tbody>
5613
5614
5615 <tr>
5616
5617 <td class="name"><code>doc</code></td>
5618
5619
5620 <td class="type">
5621
5622
5623<span class="param-type">object</span>
5624
5625
5626
5627 </td>
5628
5629
5630
5631
5632
5633 <td class="description last"><p>document to update within the collection</p></td>
5634 </tr>
5635
5636
5637 </tbody>
5638</table>
5639
5640
5641
5642
5643
5644
5645<dl class="details">
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672 <dt class="tag-source">Source:</dt>
5673 <dd class="tag-source"><ul class="dummy"><li>
5674 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line4691">line 4691</a>
5675 </li></ul></dd>
5676
5677
5678
5679
5680
5681
5682
5683</dl>
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705 <h4 class="name" id="updateWhere"><span class="type-signature"></span>updateWhere<span class="signature">(filterFunction, updateFunction)</span><span class="type-signature"></span></h4>
5706
5707
5708
5709
5710
5711<div class="description">
5712 <p>Applies a filter function and passes all results to an update function.</p>
5713</div>
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723 <h5>Parameters:</h5>
5724
5725
5726<table class="params">
5727 <thead>
5728 <tr>
5729
5730 <th>Name</th>
5731
5732
5733 <th>Type</th>
5734
5735
5736
5737
5738
5739 <th class="last">Description</th>
5740 </tr>
5741 </thead>
5742
5743 <tbody>
5744
5745
5746 <tr>
5747
5748 <td class="name"><code>filterFunction</code></td>
5749
5750
5751 <td class="type">
5752
5753
5754<span class="param-type">function</span>
5755
5756
5757
5758 </td>
5759
5760
5761
5762
5763
5764 <td class="description last"><p>filter function whose results will execute update</p></td>
5765 </tr>
5766
5767
5768
5769 <tr>
5770
5771 <td class="name"><code>updateFunction</code></td>
5772
5773
5774 <td class="type">
5775
5776
5777<span class="param-type">function</span>
5778
5779
5780
5781 </td>
5782
5783
5784
5785
5786
5787 <td class="description last"><p>update function to run against filtered documents</p></td>
5788 </tr>
5789
5790
5791 </tbody>
5792</table>
5793
5794
5795
5796
5797
5798
5799<dl class="details">
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826 <dt class="tag-source">Source:</dt>
5827 <dd class="tag-source"><ul class="dummy"><li>
5828 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line4851">line 4851</a>
5829 </li></ul></dd>
5830
5831
5832
5833
5834
5835
5836
5837</dl>
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859 <h4 class="name" id="where"><span class="type-signature"></span>where<span class="signature">(fun)</span><span class="type-signature"> &rarr; {array}</span></h4>
5860
5861
5862
5863
5864
5865<div class="description">
5866 <p>Query the collection by supplying a javascript filter function.</p>
5867</div>
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877 <h5>Parameters:</h5>
5878
5879
5880<table class="params">
5881 <thead>
5882 <tr>
5883
5884 <th>Name</th>
5885
5886
5887 <th>Type</th>
5888
5889
5890
5891
5892
5893 <th class="last">Description</th>
5894 </tr>
5895 </thead>
5896
5897 <tbody>
5898
5899
5900 <tr>
5901
5902 <td class="name"><code>fun</code></td>
5903
5904
5905 <td class="type">
5906
5907
5908<span class="param-type">function</span>
5909
5910
5911
5912 </td>
5913
5914
5915
5916
5917
5918 <td class="description last"><p>filter function to run against all collection docs</p></td>
5919 </tr>
5920
5921
5922 </tbody>
5923</table>
5924
5925
5926
5927
5928
5929
5930<dl class="details">
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957 <dt class="tag-source">Source:</dt>
5958 <dd class="tag-source"><ul class="dummy"><li>
5959 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line5544">line 5544</a>
5960 </li></ul></dd>
5961
5962
5963
5964
5965
5966
5967
5968</dl>
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982<h5>Returns:</h5>
5983
5984
5985<div class="param-desc">
5986 <p>all documents which pass your filter function</p>
5987</div>
5988
5989
5990
5991<dl>
5992 <dt>
5993 Type
5994 </dt>
5995 <dd>
5996
5997<span class="param-type">array</span>
5998
5999
6000 </dd>
6001</dl>
6002
6003
6004
6005
6006 <h5>Example</h5>
6007
6008 <pre class="prettyprint"><code>var results = coll.where(function(obj) { return obj.legs === 8; });</code></pre>
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018</article>
6019
6020</section>
6021
6022
6023
6024
6025</div>
6026
6027<nav>
6028 <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Collection.html">Collection</a></li><li><a href="DynamicView.html">DynamicView</a></li><li><a href="Loki.html">Loki</a></li><li><a href="LokiEventEmitter.html">LokiEventEmitter</a></li><li><a href="LokiFsAdapter.html">LokiFsAdapter</a></li><li><a href="LokiFsStructuredAdapter.html">LokiFsStructuredAdapter</a></li><li><a href="LokiIndexedAdapter.html">LokiIndexedAdapter</a></li><li><a href="LokiLocalStorageAdapter.html">LokiLocalStorageAdapter</a></li><li><a href="LokiMemoryAdapter.html">LokiMemoryAdapter</a></li><li><a href="LokiPartitioningAdapter.html">LokiPartitioningAdapter</a></li><li><a href="Resultset.html">Resultset</a></li></ul><h3>Tutorials</h3><ul><li><a href="tutorial-Autoupdating Collections.html">Autoupdating Collections</a></li><li><a href="tutorial-Changes API.html">Changes API</a></li><li><a href="tutorial-Collection Transforms.html">Collection Transforms</a></li><li><a href="tutorial-Indexing and Query performance.html">Indexing and Query performance</a></li><li><a href="tutorial-Loki Angular.html">Loki Angular</a></li><li><a href="tutorial-Persistence Adapters.html">Persistence Adapters</a></li><li><a href="tutorial-Query Examples.html">Query Examples</a></li></ul>
6029</nav>
6030
6031<br class="clear">
6032
6033<footer>
6034 Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Sun Dec 18 2016 19:39:52 GMT-0500 (Eastern Standard Time)
6035</footer>
6036
6037<script> prettyPrint(); </script>
6038<script src="scripts/linenumber.js"> </script>
6039</body>
6040</html>
\No newline at end of file