UNPKG

61.4 kBHTMLView Raw
1<!DOCTYPE html>
2<html lang="en">
3<head>
4 <meta charset="utf-8">
5 <title>JSDoc: Class: Loki</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: Loki</h1>
21
22
23
24
25
26
27<section>
28
29<header>
30
31 <h2>Loki</h2>
32
33
34</header>
35
36<article>
37 <div class="container-overview">
38
39
40
41
42
43 <h4 class="name" id="Loki"><span class="type-signature"></span>new Loki<span class="signature">(filename, 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>Loki: The main database class</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>filename</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>name of the file to be saved to</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">object</span>
126
127
128
129 </td>
130
131
132 <td class="attributes">
133
134 &lt;optional><br>
135
136
137
138
139
140 </td>
141
142
143
144
145 <td class="description last"><p>(Optional) config options object</p>
146 <h6>Properties</h6>
147
148
149<table class="params">
150 <thead>
151 <tr>
152
153 <th>Name</th>
154
155
156 <th>Type</th>
157
158
159
160
161
162 <th class="last">Description</th>
163 </tr>
164 </thead>
165
166 <tbody>
167
168
169 <tr>
170
171 <td class="name"><code>env</code></td>
172
173
174 <td class="type">
175
176
177<span class="param-type">string</span>
178
179
180
181 </td>
182
183
184
185
186
187 <td class="description last"><p>override environment detection as 'NODEJS', 'BROWSER', 'CORDOVA'</p></td>
188 </tr>
189
190
191
192 <tr>
193
194 <td class="name"><code>verbose</code></td>
195
196
197 <td class="type">
198
199
200<span class="param-type">boolean</span>
201
202
203
204 </td>
205
206
207
208
209
210 <td class="description last"><p>enable console output (default is 'false')</p></td>
211 </tr>
212
213
214
215 <tr>
216
217 <td class="name"><code>autosave</code></td>
218
219
220 <td class="type">
221
222
223<span class="param-type">boolean</span>
224
225
226
227 </td>
228
229
230
231
232
233 <td class="description last"><p>enables autosave</p></td>
234 </tr>
235
236
237
238 <tr>
239
240 <td class="name"><code>autosaveInterval</code></td>
241
242
243 <td class="type">
244
245
246<span class="param-type">int</span>
247
248
249
250 </td>
251
252
253
254
255
256 <td class="description last"><p>time interval (in milliseconds) between saves (if dirty)</p></td>
257 </tr>
258
259
260
261 <tr>
262
263 <td class="name"><code>autoload</code></td>
264
265
266 <td class="type">
267
268
269<span class="param-type">boolean</span>
270
271
272
273 </td>
274
275
276
277
278
279 <td class="description last"><p>enables autoload on loki instantiation</p></td>
280 </tr>
281
282
283
284 <tr>
285
286 <td class="name"><code>autoloadCallback</code></td>
287
288
289 <td class="type">
290
291
292<span class="param-type">function</span>
293
294
295
296 </td>
297
298
299
300
301
302 <td class="description last"><p>user callback called after database load</p></td>
303 </tr>
304
305
306
307 <tr>
308
309 <td class="name"><code>adapter</code></td>
310
311
312 <td class="type">
313
314
315<span class="param-type">adapter</span>
316
317
318
319 </td>
320
321
322
323
324
325 <td class="description last"><p>an instance of a loki persistence adapter</p></td>
326 </tr>
327
328
329
330 <tr>
331
332 <td class="name"><code>serializationMethod</code></td>
333
334
335 <td class="type">
336
337
338<span class="param-type">string</span>
339
340
341
342 </td>
343
344
345
346
347
348 <td class="description last"><p>['normal', 'pretty', 'destructured']</p></td>
349 </tr>
350
351
352
353 <tr>
354
355 <td class="name"><code>destructureDelimiter</code></td>
356
357
358 <td class="type">
359
360
361<span class="param-type">string</span>
362
363
364
365 </td>
366
367
368
369
370
371 <td class="description last"><p>string delimiter used for destructured serialization</p></td>
372 </tr>
373
374
375 </tbody>
376</table>
377
378 </td>
379 </tr>
380
381
382 </tbody>
383</table>
384
385
386
387
388
389
390<dl class="details">
391
392
393
394
395
396
397
398
399
400
401
402
403 <dt class="implements">Implements:</dt>
404 <dd class="implements"><ul>
405
406 <li><a href="LokiEventEmitter.html">LokiEventEmitter</a></li>
407
408 </ul></dd>
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424 <dt class="tag-source">Source:</dt>
425 <dd class="tag-source"><ul class="dummy"><li>
426 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line600">line 600</a>
427 </li></ul></dd>
428
429
430
431
432
433
434
435</dl>
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453 </div>
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468 <h3 class="subsection-title">Methods</h3>
469
470
471
472
473
474
475 <h4 class="name" id="addCollection"><span class="type-signature"></span>addCollection<span class="signature">(name, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {<a href="Collection.html">Collection</a>}</span></h4>
476
477
478
479
480
481<div class="description">
482 <p>Adds a collection to the database.</p>
483</div>
484
485
486
487
488
489
490
491
492
493 <h5>Parameters:</h5>
494
495
496<table class="params">
497 <thead>
498 <tr>
499
500 <th>Name</th>
501
502
503 <th>Type</th>
504
505
506 <th>Attributes</th>
507
508
509
510
511 <th class="last">Description</th>
512 </tr>
513 </thead>
514
515 <tbody>
516
517
518 <tr>
519
520 <td class="name"><code>name</code></td>
521
522
523 <td class="type">
524
525
526<span class="param-type">string</span>
527
528
529
530 </td>
531
532
533 <td class="attributes">
534
535
536
537
538
539 </td>
540
541
542
543
544 <td class="description last"><p>name of collection to add</p></td>
545 </tr>
546
547
548
549 <tr>
550
551 <td class="name"><code>options</code></td>
552
553
554 <td class="type">
555
556
557<span class="param-type">object</span>
558
559
560
561 </td>
562
563
564 <td class="attributes">
565
566 &lt;optional><br>
567
568
569
570
571
572 </td>
573
574
575
576
577 <td class="description last"><p>(optional) options to configure collection with.</p>
578 <h6>Properties</h6>
579
580
581<table class="params">
582 <thead>
583 <tr>
584
585 <th>Name</th>
586
587
588 <th>Type</th>
589
590
591
592
593
594 <th class="last">Description</th>
595 </tr>
596 </thead>
597
598 <tbody>
599
600
601 <tr>
602
603 <td class="name"><code>unique</code></td>
604
605
606 <td class="type">
607
608
609<span class="param-type">array</span>
610
611
612
613 </td>
614
615
616
617
618
619 <td class="description last"><p>array of property names to define unique constraints for</p></td>
620 </tr>
621
622
623
624 <tr>
625
626 <td class="name"><code>exact</code></td>
627
628
629 <td class="type">
630
631
632<span class="param-type">array</span>
633
634
635
636 </td>
637
638
639
640
641
642 <td class="description last"><p>array of property names to define exact constraints for</p></td>
643 </tr>
644
645
646
647 <tr>
648
649 <td class="name"><code>indices</code></td>
650
651
652 <td class="type">
653
654
655<span class="param-type">array</span>
656
657
658
659 </td>
660
661
662
663
664
665 <td class="description last"><p>array property names to define binary indexes for</p></td>
666 </tr>
667
668
669
670 <tr>
671
672 <td class="name"><code>asyncListeners</code></td>
673
674
675 <td class="type">
676
677
678<span class="param-type">boolean</span>
679
680
681
682 </td>
683
684
685
686
687
688 <td class="description last"><p>default is false</p></td>
689 </tr>
690
691
692
693 <tr>
694
695 <td class="name"><code>disableChangesApi</code></td>
696
697
698 <td class="type">
699
700
701<span class="param-type">boolean</span>
702
703
704
705 </td>
706
707
708
709
710
711 <td class="description last"><p>default is true</p></td>
712 </tr>
713
714
715
716 <tr>
717
718 <td class="name"><code>autoupdate</code></td>
719
720
721 <td class="type">
722
723
724<span class="param-type">boolean</span>
725
726
727
728 </td>
729
730
731
732
733
734 <td class="description last"><p>use Object.observe to update objects automatically (default: false)</p></td>
735 </tr>
736
737
738
739 <tr>
740
741 <td class="name"><code>clone</code></td>
742
743
744 <td class="type">
745
746
747<span class="param-type">boolean</span>
748
749
750
751 </td>
752
753
754
755
756
757 <td class="description last"><p>specify whether inserts and queries clone to/from user</p></td>
758 </tr>
759
760
761
762 <tr>
763
764 <td class="name"><code>cloneMethod</code></td>
765
766
767 <td class="type">
768
769
770<span class="param-type">string</span>
771
772
773
774 </td>
775
776
777
778
779
780 <td class="description last"><p>'parse-stringify' (default), 'jquery-extend-deep', 'shallow'</p></td>
781 </tr>
782
783
784
785 <tr>
786
787 <td class="name"><code>ttlInterval</code></td>
788
789
790 <td class="type">
791
792
793<span class="param-type">int</span>
794
795
796
797 </td>
798
799
800
801
802
803 <td class="description last"><p>time interval for clearing out 'aged' documents; not set by default.</p></td>
804 </tr>
805
806
807 </tbody>
808</table>
809
810 </td>
811 </tr>
812
813
814 </tbody>
815</table>
816
817
818
819
820
821
822<dl class="details">
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849 <dt class="tag-source">Source:</dt>
850 <dd class="tag-source"><ul class="dummy"><li>
851 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line894">line 894</a>
852 </li></ul></dd>
853
854
855
856
857
858
859
860</dl>
861
862
863
864
865
866
867
868
869
870
871
872
873
874<h5>Returns:</h5>
875
876
877<div class="param-desc">
878 <p>a reference to the collection which was just added</p>
879</div>
880
881
882
883<dl>
884 <dt>
885 Type
886 </dt>
887 <dd>
888
889<span class="param-type"><a href="Collection.html">Collection</a></span>
890
891
892 </dd>
893</dl>
894
895
896
897
898
899
900
901
902
903
904 <h4 class="name" id="anonym"><span class="type-signature"></span>anonym<span class="signature">(docs, options)</span><span class="type-signature"> &rarr; {<a href="Collection.html">Collection</a>}</span></h4>
905
906
907
908
909
910<div class="description">
911 <p>Shorthand method for quickly creating and populating an anonymous collection.
912 This collection is not referenced internally so upon losing scope it will be garbage collected.</p>
913</div>
914
915
916
917
918
919
920
921
922
923 <h5>Parameters:</h5>
924
925
926<table class="params">
927 <thead>
928 <tr>
929
930 <th>Name</th>
931
932
933 <th>Type</th>
934
935
936
937
938
939 <th class="last">Description</th>
940 </tr>
941 </thead>
942
943 <tbody>
944
945
946 <tr>
947
948 <td class="name"><code>docs</code></td>
949
950
951 <td class="type">
952
953
954<span class="param-type">Array</span>
955
956
957
958 </td>
959
960
961
962
963
964 <td class="description last"><p>document array to initialize the anonymous collection with</p></td>
965 </tr>
966
967
968
969 <tr>
970
971 <td class="name"><code>options</code></td>
972
973
974 <td class="type">
975
976
977<span class="param-type">object</span>
978
979
980
981 </td>
982
983
984
985
986
987 <td class="description last"><p>configuration object, see <a href="Loki.html#addCollection">Loki#addCollection</a> options</p></td>
988 </tr>
989
990
991 </tbody>
992</table>
993
994
995
996
997
998
999<dl class="details">
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026 <dt class="tag-source">Source:</dt>
1027 <dd class="tag-source"><ul class="dummy"><li>
1028 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line868">line 868</a>
1029 </li></ul></dd>
1030
1031
1032
1033
1034
1035
1036
1037</dl>
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051<h5>Returns:</h5>
1052
1053
1054<div class="param-desc">
1055 <p>New collection which you can query or chain</p>
1056</div>
1057
1058
1059
1060<dl>
1061 <dt>
1062 Type
1063 </dt>
1064 <dd>
1065
1066<span class="param-type"><a href="Collection.html">Collection</a></span>
1067
1068
1069 </dd>
1070</dl>
1071
1072
1073
1074
1075 <h5>Example</h5>
1076
1077 <pre class="prettyprint"><code>var results = new loki().anonym(myDocArray).find({'age': {'$gt': 30} });</code></pre>
1078
1079
1080
1081
1082
1083
1084
1085
1086 <h4 class="name" id="clearChanges"><span class="type-signature"></span>clearChanges<span class="signature">()</span><span class="type-signature"></span></h4>
1087
1088
1089
1090
1091
1092<div class="description">
1093 <p>(Changes API) : clears all the changes in all collections.</p>
1094</div>
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108<dl class="details">
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135 <dt class="tag-source">Source:</dt>
1136 <dd class="tag-source"><ul class="dummy"><li>
1137 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line1580">line 1580</a>
1138 </li></ul></dd>
1139
1140
1141
1142
1143
1144
1145
1146</dl>
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168 <h4 class="name" id="close"><span class="type-signature"></span>close<span class="signature">(callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
1169
1170
1171
1172
1173
1174<div class="description">
1175 <p>Emits the close event. In autosave scenarios, if the database is dirty, this will save and disable timer.
1176Does not actually destroy the db.</p>
1177</div>
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187 <h5>Parameters:</h5>
1188
1189
1190<table class="params">
1191 <thead>
1192 <tr>
1193
1194 <th>Name</th>
1195
1196
1197 <th>Type</th>
1198
1199
1200 <th>Attributes</th>
1201
1202
1203
1204
1205 <th class="last">Description</th>
1206 </tr>
1207 </thead>
1208
1209 <tbody>
1210
1211
1212 <tr>
1213
1214 <td class="name"><code>callback</code></td>
1215
1216
1217 <td class="type">
1218
1219
1220<span class="param-type">function</span>
1221
1222
1223
1224 </td>
1225
1226
1227 <td class="attributes">
1228
1229 &lt;optional><br>
1230
1231
1232
1233
1234
1235 </td>
1236
1237
1238
1239
1240 <td class="description last"><p>(Optional) if supplied will be registered with close event before emitting.</p></td>
1241 </tr>
1242
1243
1244 </tbody>
1245</table>
1246
1247
1248
1249
1250
1251
1252<dl class="details">
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279 <dt class="tag-source">Source:</dt>
1280 <dd class="tag-source"><ul class="dummy"><li>
1281 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line1516">line 1516</a>
1282 </li></ul></dd>
1283
1284
1285
1286
1287
1288
1289
1290</dl>
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312 <h4 class="name" id="configureOptions"><span class="type-signature"></span>configureOptions<span class="signature">(options, initialConfig)</span><span class="type-signature"></span></h4>
1313
1314
1315
1316
1317
1318<div class="description">
1319 <p>Allows reconfiguring database options</p>
1320</div>
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330 <h5>Parameters:</h5>
1331
1332
1333<table class="params">
1334 <thead>
1335 <tr>
1336
1337 <th>Name</th>
1338
1339
1340 <th>Type</th>
1341
1342
1343
1344
1345
1346 <th class="last">Description</th>
1347 </tr>
1348 </thead>
1349
1350 <tbody>
1351
1352
1353 <tr>
1354
1355 <td class="name"><code>options</code></td>
1356
1357
1358 <td class="type">
1359
1360
1361<span class="param-type">object</span>
1362
1363
1364
1365 </td>
1366
1367
1368
1369
1370
1371 <td class="description last"><p>configuration options to apply to loki db object</p>
1372 <h6>Properties</h6>
1373
1374
1375<table class="params">
1376 <thead>
1377 <tr>
1378
1379 <th>Name</th>
1380
1381
1382 <th>Type</th>
1383
1384
1385
1386
1387
1388 <th class="last">Description</th>
1389 </tr>
1390 </thead>
1391
1392 <tbody>
1393
1394
1395 <tr>
1396
1397 <td class="name"><code>env</code></td>
1398
1399
1400 <td class="type">
1401
1402
1403<span class="param-type">string</span>
1404
1405
1406
1407 </td>
1408
1409
1410
1411
1412
1413 <td class="description last"><p>override environment detection as 'NODEJS', 'BROWSER', 'CORDOVA'</p></td>
1414 </tr>
1415
1416
1417
1418 <tr>
1419
1420 <td class="name"><code>verbose</code></td>
1421
1422
1423 <td class="type">
1424
1425
1426<span class="param-type">boolean</span>
1427
1428
1429
1430 </td>
1431
1432
1433
1434
1435
1436 <td class="description last"><p>enable console output (default is 'false')</p></td>
1437 </tr>
1438
1439
1440
1441 <tr>
1442
1443 <td class="name"><code>autosave</code></td>
1444
1445
1446 <td class="type">
1447
1448
1449<span class="param-type">boolean</span>
1450
1451
1452
1453 </td>
1454
1455
1456
1457
1458
1459 <td class="description last"><p>enables autosave</p></td>
1460 </tr>
1461
1462
1463
1464 <tr>
1465
1466 <td class="name"><code>autosaveInterval</code></td>
1467
1468
1469 <td class="type">
1470
1471
1472<span class="param-type">int</span>
1473
1474
1475
1476 </td>
1477
1478
1479
1480
1481
1482 <td class="description last"><p>time interval (in milliseconds) between saves (if dirty)</p></td>
1483 </tr>
1484
1485
1486
1487 <tr>
1488
1489 <td class="name"><code>autoload</code></td>
1490
1491
1492 <td class="type">
1493
1494
1495<span class="param-type">boolean</span>
1496
1497
1498
1499 </td>
1500
1501
1502
1503
1504
1505 <td class="description last"><p>enables autoload on loki instantiation</p></td>
1506 </tr>
1507
1508
1509
1510 <tr>
1511
1512 <td class="name"><code>autoloadCallback</code></td>
1513
1514
1515 <td class="type">
1516
1517
1518<span class="param-type">function</span>
1519
1520
1521
1522 </td>
1523
1524
1525
1526
1527
1528 <td class="description last"><p>user callback called after database load</p></td>
1529 </tr>
1530
1531
1532
1533 <tr>
1534
1535 <td class="name"><code>adapter</code></td>
1536
1537
1538 <td class="type">
1539
1540
1541<span class="param-type">adapter</span>
1542
1543
1544
1545 </td>
1546
1547
1548
1549
1550
1551 <td class="description last"><p>an instance of a loki persistence adapter</p></td>
1552 </tr>
1553
1554
1555
1556 <tr>
1557
1558 <td class="name"><code>serializationMethod</code></td>
1559
1560
1561 <td class="type">
1562
1563
1564<span class="param-type">string</span>
1565
1566
1567
1568 </td>
1569
1570
1571
1572
1573
1574 <td class="description last"><p>['normal', 'pretty', 'destructured']</p></td>
1575 </tr>
1576
1577
1578
1579 <tr>
1580
1581 <td class="name"><code>destructureDelimiter</code></td>
1582
1583
1584 <td class="type">
1585
1586
1587<span class="param-type">string</span>
1588
1589
1590
1591 </td>
1592
1593
1594
1595
1596
1597 <td class="description last"><p>string delimiter used for destructured serialization</p></td>
1598 </tr>
1599
1600
1601 </tbody>
1602</table>
1603
1604 </td>
1605 </tr>
1606
1607
1608
1609 <tr>
1610
1611 <td class="name"><code>initialConfig</code></td>
1612
1613
1614 <td class="type">
1615
1616
1617<span class="param-type">boolean</span>
1618
1619
1620
1621 </td>
1622
1623
1624
1625
1626
1627 <td class="description last"><p>(internal) true is passed when loki ctor is invoking</p></td>
1628 </tr>
1629
1630
1631 </tbody>
1632</table>
1633
1634
1635
1636
1637
1638
1639<dl class="details">
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666 <dt class="tag-source">Source:</dt>
1667 <dd class="tag-source"><ul class="dummy"><li>
1668 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line740">line 740</a>
1669 </li></ul></dd>
1670
1671
1672
1673
1674
1675
1676
1677</dl>
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699 <h4 class="name" id="copy"><span class="type-signature"></span>copy<span class="signature">(options)</span><span class="type-signature"></span></h4>
1700
1701
1702
1703
1704
1705<div class="description">
1706 <p>Copies 'this' database into a new Loki instance. Object references are shared to make lightweight.</p>
1707</div>
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717 <h5>Parameters:</h5>
1718
1719
1720<table class="params">
1721 <thead>
1722 <tr>
1723
1724 <th>Name</th>
1725
1726
1727 <th>Type</th>
1728
1729
1730
1731
1732
1733 <th class="last">Description</th>
1734 </tr>
1735 </thead>
1736
1737 <tbody>
1738
1739
1740 <tr>
1741
1742 <td class="name"><code>options</code></td>
1743
1744
1745 <td class="type">
1746
1747
1748<span class="param-type">object</span>
1749
1750
1751
1752 </td>
1753
1754
1755
1756
1757
1758 <td class="description last"><p>apply or override collection level settings</p>
1759 <h6>Properties</h6>
1760
1761
1762<table class="params">
1763 <thead>
1764 <tr>
1765
1766 <th>Name</th>
1767
1768
1769 <th>Type</th>
1770
1771
1772
1773
1774
1775 <th class="last">Description</th>
1776 </tr>
1777 </thead>
1778
1779 <tbody>
1780
1781
1782 <tr>
1783
1784 <td class="name"><code>removeNonSerializable</code></td>
1785
1786
1787 <td class="type">
1788
1789
1790<span class="param-type">bool</span>
1791
1792
1793
1794 </td>
1795
1796
1797
1798
1799
1800 <td class="description last"><p>nulls properties not safe for serialization.</p></td>
1801 </tr>
1802
1803
1804 </tbody>
1805</table>
1806
1807 </td>
1808 </tr>
1809
1810
1811 </tbody>
1812</table>
1813
1814
1815
1816
1817
1818
1819<dl class="details">
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846 <dt class="tag-source">Source:</dt>
1847 <dd class="tag-source"><ul class="dummy"><li>
1848 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line832">line 832</a>
1849 </li></ul></dd>
1850
1851
1852
1853
1854
1855
1856
1857</dl>
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879 <h4 class="name" id="deleteDatabase"><span class="type-signature"></span>deleteDatabase<span class="signature">(options, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
1880
1881
1882
1883
1884
1885<div class="description">
1886 <p>Handles deleting a database from file system, local
1887 storage, or adapter (indexeddb)
1888 This method utilizes loki configuration options (if provided) to determine which
1889 persistence method to use, or environment detection (if configuration was not provided).</p>
1890</div>
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900 <h5>Parameters:</h5>
1901
1902
1903<table class="params">
1904 <thead>
1905 <tr>
1906
1907 <th>Name</th>
1908
1909
1910 <th>Type</th>
1911
1912
1913 <th>Attributes</th>
1914
1915
1916
1917
1918 <th class="last">Description</th>
1919 </tr>
1920 </thead>
1921
1922 <tbody>
1923
1924
1925 <tr>
1926
1927 <td class="name"><code>options</code></td>
1928
1929
1930 <td class="type">
1931
1932
1933<span class="param-type">object</span>
1934
1935
1936
1937 </td>
1938
1939
1940 <td class="attributes">
1941
1942
1943
1944
1945
1946 </td>
1947
1948
1949
1950
1951 <td class="description last"><p>not currently used (remove or allow overrides?)</p></td>
1952 </tr>
1953
1954
1955
1956 <tr>
1957
1958 <td class="name"><code>callback</code></td>
1959
1960
1961 <td class="type">
1962
1963
1964<span class="param-type">function</span>
1965
1966
1967
1968 </td>
1969
1970
1971 <td class="attributes">
1972
1973 &lt;optional><br>
1974
1975
1976
1977
1978
1979 </td>
1980
1981
1982
1983
1984 <td class="description last"><p>(Optional) user supplied async callback / error handler</p></td>
1985 </tr>
1986
1987
1988 </tbody>
1989</table>
1990
1991
1992
1993
1994
1995
1996<dl class="details">
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023 <dt class="tag-source">Source:</dt>
2024 <dd class="tag-source"><ul class="dummy"><li>
2025 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line2198">line 2198</a>
2026 </li></ul></dd>
2027
2028
2029
2030
2031
2032
2033
2034</dl>
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056 <h4 class="name" id="deserializeCollection"><span class="type-signature"></span>deserializeCollection<span class="signature">(destructuredSource, options)</span><span class="type-signature"> &rarr; {array}</span></h4>
2057
2058
2059
2060
2061
2062<div class="description">
2063 <p>Deserializes a destructured collection.</p>
2064</div>
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074 <h5>Parameters:</h5>
2075
2076
2077<table class="params">
2078 <thead>
2079 <tr>
2080
2081 <th>Name</th>
2082
2083
2084 <th>Type</th>
2085
2086
2087
2088
2089
2090 <th class="last">Description</th>
2091 </tr>
2092 </thead>
2093
2094 <tbody>
2095
2096
2097 <tr>
2098
2099 <td class="name"><code>destructuredSource</code></td>
2100
2101
2102 <td class="type">
2103
2104
2105<span class="param-type">string</span>
2106|
2107
2108<span class="param-type">array</span>
2109
2110
2111
2112 </td>
2113
2114
2115
2116
2117
2118 <td class="description last"><p>destructured representation of collection to inflate</p></td>
2119 </tr>
2120
2121
2122
2123 <tr>
2124
2125 <td class="name"><code>options</code></td>
2126
2127
2128 <td class="type">
2129
2130
2131<span class="param-type">object</span>
2132
2133
2134
2135 </td>
2136
2137
2138
2139
2140
2141 <td class="description last"><p>used to describe format of destructuredSource input</p>
2142 <h6>Properties</h6>
2143
2144
2145<table class="params">
2146 <thead>
2147 <tr>
2148
2149 <th>Name</th>
2150
2151
2152 <th>Type</th>
2153
2154
2155
2156
2157
2158 <th class="last">Description</th>
2159 </tr>
2160 </thead>
2161
2162 <tbody>
2163
2164
2165 <tr>
2166
2167 <td class="name"><code>delimited</code></td>
2168
2169
2170 <td class="type">
2171
2172
2173<span class="param-type">int</span>
2174
2175
2176
2177 </td>
2178
2179
2180
2181
2182
2183 <td class="description last"><p>whether source is delimited string or an array</p></td>
2184 </tr>
2185
2186
2187
2188 <tr>
2189
2190 <td class="name"><code>delimiter</code></td>
2191
2192
2193 <td class="type">
2194
2195
2196<span class="param-type">string</span>
2197
2198
2199
2200 </td>
2201
2202
2203
2204
2205
2206 <td class="description last"><p>(optional) if delimited, this is delimiter to use</p></td>
2207 </tr>
2208
2209
2210 </tbody>
2211</table>
2212
2213 </td>
2214 </tr>
2215
2216
2217 </tbody>
2218</table>
2219
2220
2221
2222
2223
2224
2225<dl class="details">
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252 <dt class="tag-source">Source:</dt>
2253 <dd class="tag-source"><ul class="dummy"><li>
2254 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line1321">line 1321</a>
2255 </li></ul></dd>
2256
2257
2258
2259
2260
2261
2262
2263</dl>
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277<h5>Returns:</h5>
2278
2279
2280<div class="param-desc">
2281 <p>an array of documents to attach to collection.data.</p>
2282</div>
2283
2284
2285
2286<dl>
2287 <dt>
2288 Type
2289 </dt>
2290 <dd>
2291
2292<span class="param-type">array</span>
2293
2294
2295 </dd>
2296</dl>
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307 <h4 class="name" id="deserializeDestructured"><span class="type-signature"></span>deserializeDestructured<span class="signature">(destructuredSource, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {object|array}</span></h4>
2308
2309
2310
2311
2312
2313<div class="description">
2314 <p>Destructured JSON deserialization routine to minimize memory overhead.
2315Internally, Loki supports destructuring via loki &quot;serializationMethod' option and
2316the optional LokiPartitioningAdapter class. It is also available if you wish to do
2317your own structured persistence or data exchange.</p>
2318</div>
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328 <h5>Parameters:</h5>
2329
2330
2331<table class="params">
2332 <thead>
2333 <tr>
2334
2335 <th>Name</th>
2336
2337
2338 <th>Type</th>
2339
2340
2341 <th>Attributes</th>
2342
2343
2344
2345
2346 <th class="last">Description</th>
2347 </tr>
2348 </thead>
2349
2350 <tbody>
2351
2352
2353 <tr>
2354
2355 <td class="name"><code>destructuredSource</code></td>
2356
2357
2358 <td class="type">
2359
2360
2361<span class="param-type">string</span>
2362|
2363
2364<span class="param-type">array</span>
2365
2366
2367
2368 </td>
2369
2370
2371 <td class="attributes">
2372
2373
2374
2375
2376
2377 </td>
2378
2379
2380
2381
2382 <td class="description last"><p>destructured json or array to deserialize from</p></td>
2383 </tr>
2384
2385
2386
2387 <tr>
2388
2389 <td class="name"><code>options</code></td>
2390
2391
2392 <td class="type">
2393
2394
2395<span class="param-type">object</span>
2396
2397
2398
2399 </td>
2400
2401
2402 <td class="attributes">
2403
2404 &lt;optional><br>
2405
2406
2407
2408
2409
2410 </td>
2411
2412
2413
2414
2415 <td class="description last"><p>source format options</p>
2416 <h6>Properties</h6>
2417
2418
2419<table class="params">
2420 <thead>
2421 <tr>
2422
2423 <th>Name</th>
2424
2425
2426 <th>Type</th>
2427
2428
2429 <th>Attributes</th>
2430
2431
2432
2433
2434 <th class="last">Description</th>
2435 </tr>
2436 </thead>
2437
2438 <tbody>
2439
2440
2441 <tr>
2442
2443 <td class="name"><code>partitioned</code></td>
2444
2445
2446 <td class="type">
2447
2448
2449<span class="param-type">bool</span>
2450
2451
2452
2453 </td>
2454
2455
2456 <td class="attributes">
2457
2458 &lt;optional><br>
2459
2460
2461
2462
2463
2464 </td>
2465
2466
2467
2468
2469 <td class="description last"><p>(default: false) whether db and each collection are separate</p></td>
2470 </tr>
2471
2472
2473
2474 <tr>
2475
2476 <td class="name"><code>partition</code></td>
2477
2478
2479 <td class="type">
2480
2481
2482<span class="param-type">int</span>
2483
2484
2485
2486 </td>
2487
2488
2489 <td class="attributes">
2490
2491 &lt;optional><br>
2492
2493
2494
2495
2496
2497 </td>
2498
2499
2500
2501
2502 <td class="description last"><p>can be used to deserialize only a single partition</p></td>
2503 </tr>
2504
2505
2506
2507 <tr>
2508
2509 <td class="name"><code>delimited</code></td>
2510
2511
2512 <td class="type">
2513
2514
2515<span class="param-type">bool</span>
2516
2517
2518
2519 </td>
2520
2521
2522 <td class="attributes">
2523
2524 &lt;optional><br>
2525
2526
2527
2528
2529
2530 </td>
2531
2532
2533
2534
2535 <td class="description last"><p>(default: true) whether subitems are delimited or subarrays</p></td>
2536 </tr>
2537
2538
2539
2540 <tr>
2541
2542 <td class="name"><code>delimiter</code></td>
2543
2544
2545 <td class="type">
2546
2547
2548<span class="param-type">string</span>
2549
2550
2551
2552 </td>
2553
2554
2555 <td class="attributes">
2556
2557 &lt;optional><br>
2558
2559
2560
2561
2562
2563 </td>
2564
2565
2566
2567
2568 <td class="description last"><p>override default delimiter</p></td>
2569 </tr>
2570
2571
2572 </tbody>
2573</table>
2574
2575 </td>
2576 </tr>
2577
2578
2579 </tbody>
2580</table>
2581
2582
2583
2584
2585
2586
2587<dl class="details">
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614 <dt class="tag-source">Source:</dt>
2615 <dd class="tag-source"><ul class="dummy"><li>
2616 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line1215">line 1215</a>
2617 </li></ul></dd>
2618
2619
2620
2621
2622
2623
2624
2625</dl>
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639<h5>Returns:</h5>
2640
2641
2642<div class="param-desc">
2643 <p>An object representation of the deserialized database, not yet applied to 'this' db or document array</p>
2644</div>
2645
2646
2647
2648<dl>
2649 <dt>
2650 Type
2651 </dt>
2652 <dd>
2653
2654<span class="param-type">object</span>
2655|
2656
2657<span class="param-type">array</span>
2658
2659
2660 </dd>
2661</dl>
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672 <h4 class="name" id="generateChangesNotification"><span class="type-signature"></span>generateChangesNotification<span class="signature">(optional<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {array}</span></h4>
2673
2674
2675
2676
2677
2678<div class="description">
2679 <p>(Changes API) : takes all the changes stored in each
2680collection and creates a single array for the entire database. If an array of names
2681of collections is passed then only the included collections will be tracked.</p>
2682</div>
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692 <h5>Parameters:</h5>
2693
2694
2695<table class="params">
2696 <thead>
2697 <tr>
2698
2699 <th>Name</th>
2700
2701
2702 <th>Type</th>
2703
2704
2705 <th>Attributes</th>
2706
2707
2708
2709
2710 <th class="last">Description</th>
2711 </tr>
2712 </thead>
2713
2714 <tbody>
2715
2716
2717 <tr>
2718
2719 <td class="name"><code>optional</code></td>
2720
2721
2722 <td class="type">
2723
2724
2725<span class="param-type">array</span>
2726
2727
2728
2729 </td>
2730
2731
2732 <td class="attributes">
2733
2734 &lt;optional><br>
2735
2736
2737
2738
2739
2740 </td>
2741
2742
2743
2744
2745 <td class="description last"><p>array of collection names. No arg means all collections are processed.</p></td>
2746 </tr>
2747
2748
2749 </tbody>
2750</table>
2751
2752
2753
2754
2755
2756
2757<dl class="details">
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784 <dt class="tag-source">Source:</dt>
2785 <dd class="tag-source"><ul class="dummy"><li>
2786 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line1552">line 1552</a>
2787 </li></ul></dd>
2788
2789
2790
2791
2792
2793 <dt class="tag-see">See:</dt>
2794 <dd class="tag-see">
2795 <ul>
2796 <li>private method createChange() in Collection</li>
2797 </ul>
2798 </dd>
2799
2800
2801
2802</dl>
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816<h5>Returns:</h5>
2817
2818
2819<div class="param-desc">
2820 <p>array of changes</p>
2821</div>
2822
2823
2824
2825<dl>
2826 <dt>
2827 Type
2828 </dt>
2829 <dd>
2830
2831<span class="param-type">array</span>
2832
2833
2834 </dd>
2835</dl>
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846 <h4 class="name" id="getCollection"><span class="type-signature"></span>getCollection<span class="signature">(collectionName)</span><span class="type-signature"> &rarr; {<a href="Collection.html">Collection</a>}</span></h4>
2847
2848
2849
2850
2851
2852<div class="description">
2853 <p>Retrieves reference to a collection by name.</p>
2854</div>
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864 <h5>Parameters:</h5>
2865
2866
2867<table class="params">
2868 <thead>
2869 <tr>
2870
2871 <th>Name</th>
2872
2873
2874 <th>Type</th>
2875
2876
2877
2878
2879
2880 <th class="last">Description</th>
2881 </tr>
2882 </thead>
2883
2884 <tbody>
2885
2886
2887 <tr>
2888
2889 <td class="name"><code>collectionName</code></td>
2890
2891
2892 <td class="type">
2893
2894
2895<span class="param-type">string</span>
2896
2897
2898
2899 </td>
2900
2901
2902
2903
2904
2905 <td class="description last"><p>name of collection to look up</p></td>
2906 </tr>
2907
2908
2909 </tbody>
2910</table>
2911
2912
2913
2914
2915
2916
2917<dl class="details">
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944 <dt class="tag-source">Source:</dt>
2945 <dd class="tag-source"><ul class="dummy"><li>
2946 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line917">line 917</a>
2947 </li></ul></dd>
2948
2949
2950
2951
2952
2953
2954
2955</dl>
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969<h5>Returns:</h5>
2970
2971
2972<div class="param-desc">
2973 <p>Reference to collection in database by that name, or null if not found</p>
2974</div>
2975
2976
2977
2978<dl>
2979 <dt>
2980 Type
2981 </dt>
2982 <dd>
2983
2984<span class="param-type"><a href="Collection.html">Collection</a></span>
2985
2986
2987 </dd>
2988</dl>
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999 <h4 class="name" id="loadDatabase"><span class="type-signature"></span>loadDatabase<span class="signature">(options, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
3000
3001
3002
3003
3004
3005<div class="description">
3006 <p>Handles loading from file system, local storage, or adapter (indexeddb)
3007 This method utilizes loki configuration options (if provided) to determine which
3008 persistence method to use, or environment detection (if configuration was not provided).</p>
3009</div>
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019 <h5>Parameters:</h5>
3020
3021
3022<table class="params">
3023 <thead>
3024 <tr>
3025
3026 <th>Name</th>
3027
3028
3029 <th>Type</th>
3030
3031
3032 <th>Attributes</th>
3033
3034
3035
3036
3037 <th class="last">Description</th>
3038 </tr>
3039 </thead>
3040
3041 <tbody>
3042
3043
3044 <tr>
3045
3046 <td class="name"><code>options</code></td>
3047
3048
3049 <td class="type">
3050
3051
3052<span class="param-type">object</span>
3053
3054
3055
3056 </td>
3057
3058
3059 <td class="attributes">
3060
3061
3062
3063
3064
3065 </td>
3066
3067
3068
3069
3070 <td class="description last"><p>not currently used (remove or allow overrides?)</p></td>
3071 </tr>
3072
3073
3074
3075 <tr>
3076
3077 <td class="name"><code>callback</code></td>
3078
3079
3080 <td class="type">
3081
3082
3083<span class="param-type">function</span>
3084
3085
3086
3087 </td>
3088
3089
3090 <td class="attributes">
3091
3092 &lt;optional><br>
3093
3094
3095
3096
3097
3098 </td>
3099
3100
3101
3102
3103 <td class="description last"><p>(Optional) user supplied async callback / error handler</p></td>
3104 </tr>
3105
3106
3107 </tbody>
3108</table>
3109
3110
3111
3112
3113
3114
3115<dl class="details">
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142 <dt class="tag-source">Source:</dt>
3143 <dd class="tag-source"><ul class="dummy"><li>
3144 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line2104">line 2104</a>
3145 </li></ul></dd>
3146
3147
3148
3149
3150
3151
3152
3153</dl>
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175 <h4 class="name" id="loadJSON"><span class="type-signature"></span>loadJSON<span class="signature">(serializedDb, options)</span><span class="type-signature"></span></h4>
3176
3177
3178
3179
3180
3181<div class="description">
3182 <p>Inflates a loki database from a serialized JSON string</p>
3183</div>
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193 <h5>Parameters:</h5>
3194
3195
3196<table class="params">
3197 <thead>
3198 <tr>
3199
3200 <th>Name</th>
3201
3202
3203 <th>Type</th>
3204
3205
3206
3207
3208
3209 <th class="last">Description</th>
3210 </tr>
3211 </thead>
3212
3213 <tbody>
3214
3215
3216 <tr>
3217
3218 <td class="name"><code>serializedDb</code></td>
3219
3220
3221 <td class="type">
3222
3223
3224<span class="param-type">string</span>
3225
3226
3227
3228 </td>
3229
3230
3231
3232
3233
3234 <td class="description last"><p>a serialized loki database string</p></td>
3235 </tr>
3236
3237
3238
3239 <tr>
3240
3241 <td class="name"><code>options</code></td>
3242
3243
3244 <td class="type">
3245
3246
3247<span class="param-type">object</span>
3248
3249
3250
3251 </td>
3252
3253
3254
3255
3256
3257 <td class="description last"><p>apply or override collection level settings</p></td>
3258 </tr>
3259
3260
3261 </tbody>
3262</table>
3263
3264
3265
3266
3267
3268
3269<dl class="details">
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296 <dt class="tag-source">Source:</dt>
3297 <dd class="tag-source"><ul class="dummy"><li>
3298 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line1362">line 1362</a>
3299 </li></ul></dd>
3300
3301
3302
3303
3304
3305
3306
3307</dl>
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329 <h4 class="name" id="loadJSONObject"><span class="type-signature"></span>loadJSONObject<span class="signature">(dbObject, options)</span><span class="type-signature"></span></h4>
3330
3331
3332
3333
3334
3335<div class="description">
3336 <p>Inflates a loki database from a JS object</p>
3337</div>
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347 <h5>Parameters:</h5>
3348
3349
3350<table class="params">
3351 <thead>
3352 <tr>
3353
3354 <th>Name</th>
3355
3356
3357 <th>Type</th>
3358
3359
3360
3361
3362
3363 <th class="last">Description</th>
3364 </tr>
3365 </thead>
3366
3367 <tbody>
3368
3369
3370 <tr>
3371
3372 <td class="name"><code>dbObject</code></td>
3373
3374
3375 <td class="type">
3376
3377
3378<span class="param-type">object</span>
3379
3380
3381
3382 </td>
3383
3384
3385
3386
3387
3388 <td class="description last"><p>a serialized loki database string</p></td>
3389 </tr>
3390
3391
3392
3393 <tr>
3394
3395 <td class="name"><code>options</code></td>
3396
3397
3398 <td class="type">
3399
3400
3401<span class="param-type">object</span>
3402
3403
3404
3405 </td>
3406
3407
3408
3409
3410
3411 <td class="description last"><p>apply or override collection level settings</p>
3412 <h6>Properties</h6>
3413
3414
3415<table class="params">
3416 <thead>
3417 <tr>
3418
3419 <th>Name</th>
3420
3421
3422 <th>Type</th>
3423
3424
3425 <th>Attributes</th>
3426
3427
3428
3429
3430 <th class="last">Description</th>
3431 </tr>
3432 </thead>
3433
3434 <tbody>
3435
3436
3437 <tr>
3438
3439 <td class="name"><code>retainDirtyFlags</code></td>
3440
3441
3442 <td class="type">
3443
3444
3445<span class="param-type">bool</span>
3446
3447
3448
3449 </td>
3450
3451
3452 <td class="attributes">
3453
3454
3455
3456 &lt;nullable><br>
3457
3458
3459
3460 </td>
3461
3462
3463
3464
3465 <td class="description last"><p>whether collection dirty flags will be preserved</p></td>
3466 </tr>
3467
3468
3469 </tbody>
3470</table>
3471
3472 </td>
3473 </tr>
3474
3475
3476 </tbody>
3477</table>
3478
3479
3480
3481
3482
3483
3484<dl class="details">
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511 <dt class="tag-source">Source:</dt>
3512 <dd class="tag-source"><ul class="dummy"><li>
3513 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line1387">line 1387</a>
3514 </li></ul></dd>
3515
3516
3517
3518
3519
3520
3521
3522</dl>
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544 <h4 class="name" id="removeCollection"><span class="type-signature"></span>removeCollection<span class="signature">(collectionName)</span><span class="type-signature"></span></h4>
3545
3546
3547
3548
3549
3550<div class="description">
3551 <p>Removes a collection from the database.</p>
3552</div>
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562 <h5>Parameters:</h5>
3563
3564
3565<table class="params">
3566 <thead>
3567 <tr>
3568
3569 <th>Name</th>
3570
3571
3572 <th>Type</th>
3573
3574
3575
3576
3577
3578 <th class="last">Description</th>
3579 </tr>
3580 </thead>
3581
3582 <tbody>
3583
3584
3585 <tr>
3586
3587 <td class="name"><code>collectionName</code></td>
3588
3589
3590 <td class="type">
3591
3592
3593<span class="param-type">string</span>
3594
3595
3596
3597 </td>
3598
3599
3600
3601
3602
3603 <td class="description last"><p>name of collection to remove</p></td>
3604 </tr>
3605
3606
3607 </tbody>
3608</table>
3609
3610
3611
3612
3613
3614
3615<dl class="details">
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642 <dt class="tag-source">Source:</dt>
3643 <dd class="tag-source"><ul class="dummy"><li>
3644 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line952">line 952</a>
3645 </li></ul></dd>
3646
3647
3648
3649
3650
3651
3652
3653</dl>
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675 <h4 class="name" id="saveDatabase"><span class="type-signature"></span>saveDatabase<span class="signature">(callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
3676
3677
3678
3679
3680
3681<div class="description">
3682 <p>Handles saving to file system, local storage, or adapter (indexeddb)
3683 This method utilizes loki configuration options (if provided) to determine which
3684 persistence method to use, or environment detection (if configuration was not provided).</p>
3685</div>
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695 <h5>Parameters:</h5>
3696
3697
3698<table class="params">
3699 <thead>
3700 <tr>
3701
3702 <th>Name</th>
3703
3704
3705 <th>Type</th>
3706
3707
3708 <th>Attributes</th>
3709
3710
3711
3712
3713 <th class="last">Description</th>
3714 </tr>
3715 </thead>
3716
3717 <tbody>
3718
3719
3720 <tr>
3721
3722 <td class="name"><code>callback</code></td>
3723
3724
3725 <td class="type">
3726
3727
3728<span class="param-type">function</span>
3729
3730
3731
3732 </td>
3733
3734
3735 <td class="attributes">
3736
3737 &lt;optional><br>
3738
3739
3740
3741
3742
3743 </td>
3744
3745
3746
3747
3748 <td class="description last"><p>(Optional) user supplied async callback / error handler</p></td>
3749 </tr>
3750
3751
3752 </tbody>
3753</table>
3754
3755
3756
3757
3758
3759
3760<dl class="details">
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787 <dt class="tag-source">Source:</dt>
3788 <dd class="tag-source"><ul class="dummy"><li>
3789 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line2154">line 2154</a>
3790 </li></ul></dd>
3791
3792
3793
3794
3795
3796
3797
3798</dl>
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820 <h4 class="name" id="serialize"><span class="type-signature"></span>serialize<span class="signature">()</span><span class="type-signature"> &rarr; {string}</span></h4>
3821
3822
3823
3824
3825
3826<div class="description">
3827 <p>Serialize database to a string which can be loaded via <a href="Loki.html#loadJSON">Loki#loadJSON</a></p>
3828</div>
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842<dl class="details">
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869 <dt class="tag-source">Source:</dt>
3870 <dd class="tag-source"><ul class="dummy"><li>
3871 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line997">line 997</a>
3872 </li></ul></dd>
3873
3874
3875
3876
3877
3878
3879
3880</dl>
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894<h5>Returns:</h5>
3895
3896
3897<div class="param-desc">
3898 <p>Stringified representation of the loki database.</p>
3899</div>
3900
3901
3902
3903<dl>
3904 <dt>
3905 Type
3906 </dt>
3907 <dd>
3908
3909<span class="param-type">string</span>
3910
3911
3912 </dd>
3913</dl>
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924 <h4 class="name" id="serializeChanges"><span class="type-signature"></span>serializeChanges<span class="signature">()</span><span class="type-signature"> &rarr; {string}</span></h4>
3925
3926
3927
3928
3929
3930<div class="description">
3931 <p>(Changes API) - stringify changes for network transmission</p>
3932</div>
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946<dl class="details">
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973 <dt class="tag-source">Source:</dt>
3974 <dd class="tag-source"><ul class="dummy"><li>
3975 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line1572">line 1572</a>
3976 </li></ul></dd>
3977
3978
3979
3980
3981
3982
3983
3984</dl>
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998<h5>Returns:</h5>
3999
4000
4001<div class="param-desc">
4002 <p>string representation of the changes</p>
4003</div>
4004
4005
4006
4007<dl>
4008 <dt>
4009 Type
4010 </dt>
4011 <dd>
4012
4013<span class="param-type">string</span>
4014
4015
4016 </dd>
4017</dl>
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028 <h4 class="name" id="serializeCollection"><span class="type-signature"></span>serializeCollection<span class="signature">(options)</span><span class="type-signature"> &rarr; {string|array}</span></h4>
4029
4030
4031
4032
4033
4034<div class="description">
4035 <p>Utility method to serialize a collection in a 'destructured' format</p>
4036</div>
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046 <h5>Parameters:</h5>
4047
4048
4049<table class="params">
4050 <thead>
4051 <tr>
4052
4053 <th>Name</th>
4054
4055
4056 <th>Type</th>
4057
4058
4059
4060
4061
4062 <th class="last">Description</th>
4063 </tr>
4064 </thead>
4065
4066 <tbody>
4067
4068
4069 <tr>
4070
4071 <td class="name"><code>options</code></td>
4072
4073
4074 <td class="type">
4075
4076
4077<span class="param-type">object</span>
4078
4079
4080
4081 </td>
4082
4083
4084
4085
4086
4087 <td class="description last"><p>used to determine output of method</p>
4088 <h6>Properties</h6>
4089
4090
4091<table class="params">
4092 <thead>
4093 <tr>
4094
4095 <th>Name</th>
4096
4097
4098 <th>Type</th>
4099
4100
4101 <th>Attributes</th>
4102
4103
4104
4105
4106 <th class="last">Description</th>
4107 </tr>
4108 </thead>
4109
4110 <tbody>
4111
4112
4113 <tr>
4114
4115 <td class="name"><code>delimited</code></td>
4116
4117
4118 <td class="type">
4119
4120
4121<span class="param-type">int</span>
4122
4123
4124
4125 </td>
4126
4127
4128 <td class="attributes">
4129
4130 &lt;optional><br>
4131
4132
4133
4134
4135
4136 </td>
4137
4138
4139
4140
4141 <td class="description last"><p>whether to return single delimited string or an array</p></td>
4142 </tr>
4143
4144
4145
4146 <tr>
4147
4148 <td class="name"><code>delimiter</code></td>
4149
4150
4151 <td class="type">
4152
4153
4154<span class="param-type">string</span>
4155
4156
4157
4158 </td>
4159
4160
4161 <td class="attributes">
4162
4163 &lt;optional><br>
4164
4165
4166
4167
4168
4169 </td>
4170
4171
4172
4173
4174 <td class="description last"><p>(optional) if delimited, this is delimiter to use</p></td>
4175 </tr>
4176
4177
4178
4179 <tr>
4180
4181 <td class="name"><code>collectionIndex</code></td>
4182
4183
4184 <td class="type">
4185
4186
4187<span class="param-type">int</span>
4188
4189
4190
4191 </td>
4192
4193
4194 <td class="attributes">
4195
4196
4197
4198
4199
4200 </td>
4201
4202
4203
4204
4205 <td class="description last"><p>specify which collection to serialize data for</p></td>
4206 </tr>
4207
4208
4209 </tbody>
4210</table>
4211
4212 </td>
4213 </tr>
4214
4215
4216 </tbody>
4217</table>
4218
4219
4220
4221
4222
4223
4224<dl class="details">
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251 <dt class="tag-source">Source:</dt>
4252 <dd class="tag-source"><ul class="dummy"><li>
4253 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line1163">line 1163</a>
4254 </li></ul></dd>
4255
4256
4257
4258
4259
4260
4261
4262</dl>
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276<h5>Returns:</h5>
4277
4278
4279<div class="param-desc">
4280 <p>A custom, restructured aggregation of independent serializations for a single collection.</p>
4281</div>
4282
4283
4284
4285<dl>
4286 <dt>
4287 Type
4288 </dt>
4289 <dd>
4290
4291<span class="param-type">string</span>
4292|
4293
4294<span class="param-type">array</span>
4295
4296
4297 </dd>
4298</dl>
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309 <h4 class="name" id="serializeDestructured"><span class="type-signature"></span>serializeDestructured<span class="signature">(options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {string|array}</span></h4>
4310
4311
4312
4313
4314
4315<div class="description">
4316 <p>Destructured JSON serialization routine to allow alternate serialization methods.
4317Internally, Loki supports destructuring via loki &quot;serializationMethod' option and
4318the optional LokiPartitioningAdapter class. It is also available if you wish to do
4319your own structured persistence or data exchange.</p>
4320</div>
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330 <h5>Parameters:</h5>
4331
4332
4333<table class="params">
4334 <thead>
4335 <tr>
4336
4337 <th>Name</th>
4338
4339
4340 <th>Type</th>
4341
4342
4343 <th>Attributes</th>
4344
4345
4346
4347
4348 <th class="last">Description</th>
4349 </tr>
4350 </thead>
4351
4352 <tbody>
4353
4354
4355 <tr>
4356
4357 <td class="name"><code>options</code></td>
4358
4359
4360 <td class="type">
4361
4362
4363<span class="param-type">object</span>
4364
4365
4366
4367 </td>
4368
4369
4370 <td class="attributes">
4371
4372 &lt;optional><br>
4373
4374
4375
4376
4377
4378 </td>
4379
4380
4381
4382
4383 <td class="description last"><p>output format options for use externally to loki</p>
4384 <h6>Properties</h6>
4385
4386
4387<table class="params">
4388 <thead>
4389 <tr>
4390
4391 <th>Name</th>
4392
4393
4394 <th>Type</th>
4395
4396
4397 <th>Attributes</th>
4398
4399
4400
4401
4402 <th class="last">Description</th>
4403 </tr>
4404 </thead>
4405
4406 <tbody>
4407
4408
4409 <tr>
4410
4411 <td class="name"><code>partitioned</code></td>
4412
4413
4414 <td class="type">
4415
4416
4417<span class="param-type">bool</span>
4418
4419
4420
4421 </td>
4422
4423
4424 <td class="attributes">
4425
4426 &lt;optional><br>
4427
4428
4429
4430
4431
4432 </td>
4433
4434
4435
4436
4437 <td class="description last"><p>(default: false) whether db and each collection are separate</p></td>
4438 </tr>
4439
4440
4441
4442 <tr>
4443
4444 <td class="name"><code>partition</code></td>
4445
4446
4447 <td class="type">
4448
4449
4450<span class="param-type">int</span>
4451
4452
4453
4454 </td>
4455
4456
4457 <td class="attributes">
4458
4459 &lt;optional><br>
4460
4461
4462
4463
4464
4465 </td>
4466
4467
4468
4469
4470 <td class="description last"><p>can be used to only output an individual collection or db (-1)</p></td>
4471 </tr>
4472
4473
4474
4475 <tr>
4476
4477 <td class="name"><code>delimited</code></td>
4478
4479
4480 <td class="type">
4481
4482
4483<span class="param-type">bool</span>
4484
4485
4486
4487 </td>
4488
4489
4490 <td class="attributes">
4491
4492 &lt;optional><br>
4493
4494
4495
4496
4497
4498 </td>
4499
4500
4501
4502
4503 <td class="description last"><p>(default: true) whether subitems are delimited or subarrays</p></td>
4504 </tr>
4505
4506
4507
4508 <tr>
4509
4510 <td class="name"><code>delimiter</code></td>
4511
4512
4513 <td class="type">
4514
4515
4516<span class="param-type">string</span>
4517
4518
4519
4520 </td>
4521
4522
4523 <td class="attributes">
4524
4525 &lt;optional><br>
4526
4527
4528
4529
4530
4531 </td>
4532
4533
4534
4535
4536 <td class="description last"><p>override default delimiter</p></td>
4537 </tr>
4538
4539
4540 </tbody>
4541</table>
4542
4543 </td>
4544 </tr>
4545
4546
4547 </tbody>
4548</table>
4549
4550
4551
4552
4553
4554
4555<dl class="details">
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582 <dt class="tag-source">Source:</dt>
4583 <dd class="tag-source"><ul class="dummy"><li>
4584 <a href="lokijs.js.html">lokijs.js</a>, <a href="lokijs.js.html#line1030">line 1030</a>
4585 </li></ul></dd>
4586
4587
4588
4589
4590
4591
4592
4593</dl>
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607<h5>Returns:</h5>
4608
4609
4610<div class="param-desc">
4611 <p>A custom, restructured aggregation of independent serializations.</p>
4612</div>
4613
4614
4615
4616<dl>
4617 <dt>
4618 Type
4619 </dt>
4620 <dd>
4621
4622<span class="param-type">string</span>
4623|
4624
4625<span class="param-type">array</span>
4626
4627
4628 </dd>
4629</dl>
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641</article>
4642
4643</section>
4644
4645
4646
4647
4648</div>
4649
4650<nav>
4651 <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>
4652</nav>
4653
4654<br class="clear">
4655
4656<footer>
4657 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)
4658</footer>
4659
4660<script> prettyPrint(); </script>
4661<script src="scripts/linenumber.js"> </script>
4662</body>
4663</html>
\No newline at end of file