-
Notifications
You must be signed in to change notification settings - Fork 16
/
mongodb.database.txt
4346 lines (3982 loc) · 293 KB
/
mongodb.database.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
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
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
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
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
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
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
MONGODB
Todo:
- Prisma:
- https://www.prisma.io/docs/concepts/database-connectors/mongodb
- https://www.prisma.io/docs/guides/database/mongodb
The following are docs of the updates from 3.0.2 to 3.4.9
Should wait for 3.6, then go through whole doc again for anything between 3.4.9 and 3.6, then actually add the new doc
$type:
https://docs.mongodb.com/manual/reference/operator/query/type/#op._S_type
find():
https://docs.mongodb.com/manual/reference/command/find/#dbcmd.find
https://docs.mongodb.com/manual/reference/command/getMore/#dbcmd.getMore
combined methods:
https://docs.mongodb.com/manual/reference/method/db.collection.findOneAndDelete/#db.collection.findOneAndDelete
https://docs.mongodb.com/manual/reference/method/db.collection.findOneAndReplace/#db.collection.findOneAndReplace
https://docs.mongodb.com/manual/reference/method/db.collection.findOneAndUpdate/#db.collection.findOneAndUpdate
one vs many:
https://docs.mongodb.com/manual/reference/method/db.collection.insertOne/#db.collection.insertOne
https://docs.mongodb.com/manual/reference/method/db.collection.insertMany/#db.collection.insertMany
https://docs.mongodb.com/manual/reference/method/db.collection.replaceOne/#db.collection.replaceOne
https://docs.mongodb.com/manual/reference/method/db.collection.updateOne/#db.collection.updateOne
https://docs.mongodb.com/manual/reference/method/db.collection.updateMany/#db.collection.updateMany
https://docs.mongodb.com/manual/reference/method/db.collection.deleteOne/#db.collection.deleteOne (not marked as new, but is
new)
https://docs.mongodb.com/manual/reference/method/db.collection.deleteMany/ (not marked as new, but is new)
NumberDecimal:
https://docs.mongodb.com/manual/reference/mongodb-extended-json/
https://docs.mongodb.com/manual/core/shell-types/
https://docs.mongodb.com/manual/tutorial/model-monetary-data/
cursors:
https://docs.mongodb.com/manual/reference/command/killCursors/#dbcmd.killCursors
https://docs.mongodb.com/manual/reference/command/cursorInfo/#dbcmd.cursorInfo
explain:
https://docs.mongodb.com/manual/reference/command/explain/#dbcmd.explain
https://docs.mongodb.com/manual/reference/method/db.collection.explain/#db.collection.explain
HTTP interface:
https://docs.mongodb.com/manual/reference/program/mongod/
https://docs.mongodb.com/manual/reference/program/mongos/
https://docs.mongodb.com/manual/reference/program/mongostat/
https://docs.mongodb.com/manual/reference/configuration-options/
Roles:
https://docs.mongodb.com/manual/core/security-built-in-roles/
https://docs.mongodb.com/manual/reference/built-in-roles/
https://docs.mongodb.com/manual/reference/program/mongodump/
Authentication:
https://docs.mongodb.com/manual/tutorial/enforce-keyfile-access-control-in-existing-replica-set-without-downtime/
https://docs.mongodb.com/manual/reference/program/mongod/
https://docs.mongodb.com/manual/reference/program/mongos/
https://docs.mongodb.com/manual/reference/configuration-options/
system.profile:
https://docs.mongodb.com/manual/reference/database-profiler/
SSL:
https://docs.mongodb.com/manual/tutorial/configure-ssl/
https://docs.mongodb.com/manual/tutorial/configure-ssl-clients/
https://docs.mongodb.com/manual/tutorial/upgrade-cluster-to-ssl/
https://docs.mongodb.com/manual/reference/program/mongod/
https://docs.mongodb.com/manual/reference/program/mongos/
https://docs.mongodb.com/manual/reference/program/mongo/
https://docs.mongodb.com/manual/reference/program/mongodump/
https://docs.mongodb.com/manual/reference/program/mongorestore/
https://docs.mongodb.com/manual/reference/program/mongoimport/
https://docs.mongodb.com/manual/reference/program/mongoexport/
https://docs.mongodb.com/manual/reference/program/mongostat/
https://docs.mongodb.com/manual/reference/program/mongotop/
https://docs.mongodb.com/manual/reference/program/mongofiles/
https://docs.mongodb.com/manual/reference/configuration-options/
https://docs.mongodb.com/manual/reference/parameters/
LDAP:
https://docs.mongodb.com/manual/core/authentication-mechanisms-enterprise/
https://docs.mongodb.com/manual/tutorial/kerberos-auth-activedirectory-authz/
https://docs.mongodb.com/manual/core/security-ldap/
https://docs.mongodb.com/manual/tutorial/configure-ldap-sasl-activedirectory/
https://docs.mongodb.com/manual/tutorial/configure-ldap-sasl-openldap/
https://docs.mongodb.com/manual/tutorial/authenticate-nativeldap-activedirectory/
https://docs.mongodb.com/manual/core/security-ldap-external/
https://docs.mongodb.com/manual/reference/program/mongoldap/
https://docs.mongodb.com/manual/reference/program/mongod/
https://docs.mongodb.com/manual/reference/program/mongos/
https://docs.mongodb.com/manual/reference/configuration-options/
Audit log:
https://docs.mongodb.com/manual/reference/program/mongod/
https://docs.mongodb.com/manual/reference/program/mongos/
https://docs.mongodb.com/manual/reference/configuration-options/
https://docs.mongodb.com/manual/administration/monitoring/
Encryption:
https://docs.mongodb.com/manual/core/security-encryption-at-rest/
https://docs.mongodb.com/manual/tutorial/configure-encryption/
https://docs.mongodb.com/manual/tutorial/rotate-encryption-key/
https://docs.mongodb.com/manual/reference/program/mongod/
https://docs.mongodb.com/manual/reference/configuration-options/
Namespaces:
https://docs.mongodb.com/manual/reference/program/mongorestore/
Dry runs:
https://docs.mongodb.com/manual/reference/program/mongorestore/
Oplog:
https://docs.mongodb.com/manual/reference/program/mongooplog/
https://docs.mongodb.com/manual/reference/program/mongorestore/
https://docs.mongodb.com/manual/reference/glossary/
https://docs.mongodb.com/manual/administration/production-checklist-operations/
import/export:
https://docs.mongodb.com/manual/reference/program/mongoimport/
mongostat:
https://docs.mongodb.com/manual/reference/program/mongostat/
mongo files ID:
https://docs.mongodb.com/manual/reference/program/mongofiles/
mongoreplay:
https://docs.mongodb.com/manual/reference/program/mongoreplay/
Logging:
https://docs.mongodb.com/manual/reference/configuration-options/
https://docs.mongodb.com/manual/reference/parameters/
https://docs.mongodb.com/manual/reference/log-messages/
Network compression:
https://docs.mongodb.com/manual/reference/program/mongod/
https://docs.mongodb.com/manual/reference/program/mongos/
https://docs.mongodb.com/manual/reference/program/mongo/
https://docs.mongodb.com/manual/reference/configuration-options/
Dump compression:
https://docs.mongodb.com/manual/reference/program/mongorestore/
listDatabases:
https://docs.mongodb.com/manual/reference/command/listDatabases/#dbcmd.listDatabases
killOp:
https://docs.mongodb.com/manual/reference/privilege-actions/
https://docs.mongodb.com/manual/reference/command/killOp/#dbcmd.killOp
https://docs.mongodb.com/manual/reference/method/db.killOp/#db.killOp
compat:
https://docs.mongodb.com/manual/reference/command/setFeatureCompatibilityVersion/#dbcmd.setFeatureCompatibilityVersion
writeConcern/readConcern:
https://docs.mongodb.com/manual/reference/read-concern/
https://docs.mongodb.com/manual/reference/write-concern/
https://docs.mongodb.com/manual/core/read-isolation-consistency-recency/
https://docs.mongodb.com/manual/administration/production-notes/
https://docs.mongodb.com/manual/tutorial/perform-findAndModify-linearizable-reads/
https://docs.mongodb.com/manual/faq/concurrency/
https://docs.mongodb.com/manual/reference/command/findAndModify/#dbcmd.findAndModify
https://docs.mongodb.com/manual/reference/method/db.collection.count/#db.collection.count
https://docs.mongodb.com/manual/reference/method/db.collection.findAndModify/#db.collection.findAndModify
https://docs.mongodb.com/manual/reference/method/cursor.readConcern/#cursor.readConcern
https://docs.mongodb.com/manual/reference/program/mongod/
https://docs.mongodb.com/manual/reference/configuration-options/
https://docs.mongodb.com/manual/reference/connection-string/
Read preference:
https://docs.mongodb.com/manual/core/read-preference/
https://docs.mongodb.com/manual/core/read-preference-mechanics/
https://docs.mongodb.com/manual/reference/connection-string/
journal:
https://docs.mongodb.com/manual/core/journaling/
https://docs.mongodb.com/manual/reference/program/mongod/
https://docs.mongodb.com/manual/reference/configuration-options/
capped collections:
https://docs.mongodb.com/manual/core/capped-collections/
indexes:
https://docs.mongodb.com/manual/indexes/
https://docs.mongodb.com/manual/core/index-partial/
https://docs.mongodb.com/manual/core/index-multikey/
https://docs.mongodb.com/manual/core/multikey-index-bounds/
https://docs.mongodb.com/manual/core/index-unique/
https://docs.mongodb.com/manual/core/index-case-insensitive/
https://docs.mongodb.com/manual/core/index-sparse/
https://docs.mongodb.com/manual/reference/command/create/#dbcmd.create
https://docs.mongodb.com/manual/reference/method/db.createCollection/#db.createCollection
https://docs.mongodb.com/manual/reference/command/createIndexes/#dbcmd.createIndexes
https://docs.mongodb.com/manual/reference/method/db.collection.createIndex/#db.collection.createIndex
https://docs.mongodb.com/manual/reference/method/cursor.returnKey/#cursor.returnKey
text search:
https://docs.mongodb.com/manual/tutorial/text-search-with-rlp/
https://docs.mongodb.com/manual/core/index-text/
https://docs.mongodb.com/manual/reference/text-search-languages/
https://docs.mongodb.com/manual/reference/operator/query/text/#op._S_text
https://docs.mongodb.com/manual/reference/program/mongod/
https://docs.mongodb.com/manual/reference/program/mongos/
https://docs.mongodb.com/manual/reference/configuration-options/
geo search:
https://docs.mongodb.com/manual/core/2dsphere/
https://docs.mongodb.com/manual/reference/operator/aggregation/geoNear/#pipe._S_geoNear
storage engines:
https://docs.mongodb.com/manual/administration/production-notes/
https://docs.mongodb.com/manual/tutorial/backup-with-filesystem-snapshots/
https://docs.mongodb.com/manual/tutorial/backup-sharded-cluster-with-filesystem-snapshots/
https://docs.mongodb.com/manual/tutorial/backup-sharded-cluster-with-database-dumps/
https://docs.mongodb.com/manual/core/wiredtiger/
https://docs.mongodb.com/manual/tutorial/change-standalone-wiredtiger/
https://docs.mongodb.com/manual/tutorial/change-replica-set-wiredtiger/
https://docs.mongodb.com/manual/core/inmemory/
https://docs.mongodb.com/manual/reference/program/mongod/
https://docs.mongodb.com/manual/reference/command/moveChunk/#dbcmd.moveChunk
https://docs.mongodb.com/manual/reference/command/create/#dbcmd.create
https://docs.mongodb.com/manual/reference/method/db.createCollection/#db.createCollection
https://docs.mongodb.com/manual/reference/command/fsync/#dbcmd.fsync
https://docs.mongodb.com/manual/reference/method/db.fsyncLock/#db.fsyncLock
https://docs.mongodb.com/manual/reference/method/db.fsyncUnlock/#db.fsyncUnlock
https://docs.mongodb.com/manual/reference/command/buildInfo/#dbcmd.buildInfo
https://docs.mongodb.com/manual/reference/configuration-options/
JavaScript engines:
https://docs.mongodb.com/manual/reference/command/buildInfo/#dbcmd.buildInfo
https://docs.mongodb.com/manual/reference/program/mongo/
https://docs.mongodb.com/manual/reference/parameters/
views:
https://docs.mongodb.com/manual/core/views/
https://docs.mongodb.com/manual/reference/method/db.createView/#db.createView
https://docs.mongodb.com/manual/reference/command/create/#dbcmd.create
https://docs.mongodb.com/manual/reference/method/db.createCollection/#db.createCollection
https://docs.mongodb.com/manual/reference/program/mongodump/
replication:
https://docs.mongodb.com/manual/replication/
https://docs.mongodb.com/manual/core/replica-set-sync/
https://docs.mongodb.com/manual/core/replica-set-elections/
https://docs.mongodb.com/manual/reference/replica-set-protocol-versions/
https://docs.mongodb.com/manual/core/master-slave/
https://docs.mongodb.com/manual/tutorial/adjust-replica-set-member-priority/
https://docs.mongodb.com/manual/reference/replica-configuration/
https://docs.mongodb.com/manual/reference/command/isMaster/#dbcmd.isMaster
https://docs.mongodb.com/manual/reference/command/replSetReconfig/#dbcmd.replSetReconfig
https://docs.mongodb.com/manual/reference/method/rs.reconfig/#rs.reconfig
https://docs.mongodb.com/manual/reference/command/replSetSyncFrom/#dbcmd.replSetSyncFrom
https://docs.mongodb.com/manual/reference/method/rs.syncFrom/#rs.syncFrom
https://docs.mongodb.com/manual/reference/command/replSetGetStatus/#dbcmd.replSetGetStatus
https://docs.mongodb.com/manual/reference/command/serverStatus/#dbcmd.serverStatus
https://docs.mongodb.com/manual/reference/program/mongod/
https://docs.mongodb.com/manual/reference/program/mongodump/
https://docs.mongodb.com/manual/reference/program/mongoexport/
https://docs.mongodb.com/manual/reference/parameters/
sharding:
https://docs.mongodb.com/manual/administration/configuration/
https://docs.mongodb.com/manual/tutorial/upgrade-revision/
https://docs.mongodb.com/manual/tutorial/restore-sharded-cluster/
https://docs.mongodb.com/manual/sharding/
https://docs.mongodb.com/manual/core/sharded-cluster-config-servers/
https://docs.mongodb.com/manual/core/sharded-cluster-query-router/
https://docs.mongodb.com/manual/tutorial/create-chunks-in-sharded-cluster/
https://docs.mongodb.com/manual/core/sharding-balancer-administration/
https://docs.mongodb.com/manual/tutorial/manage-sharded-cluster-balancer/
https://docs.mongodb.com/manual/tutorial/replace-config-server/
https://docs.mongodb.com/manual/tutorial/upgrade-config-servers-to-replica-set/
https://docs.mongodb.com/manual/tutorial/upgrade-config-servers-to-replica-set-downtime/
https://docs.mongodb.com/manual/tutorial/migrate-sharded-cluster-to-new-hardware/
https://docs.mongodb.com/manual/tutorial/convert-replica-set-to-replicated-shard-cluster/
https://docs.mongodb.com/manual/tutorial/troubleshoot-sharded-clusters/
https://docs.mongodb.com/manual/reference/config-database/
https://docs.mongodb.com/manual/reference/command/addShardToZone/#dbcmd.addShardToZone
https://docs.mongodb.com/manual/reference/method/sh.addShardToZone/#sh.addShardToZone
https://docs.mongodb.com/manual/reference/command/removeShardFromZone/#dbcmd.removeShardFromZone
https://docs.mongodb.com/manual/reference/method/sh.removeShardFromZone/#sh.removeShardFromZone
https://docs.mongodb.com/manual/reference/method/sh.removeRangeFromZone/#sh.removeRangeFromZone
https://docs.mongodb.com/manual/reference/command/updateZoneKeyRange/#dbcmd.updateZoneKeyRange
https://docs.mongodb.com/manual/reference/method/sh.updateZoneKeyRange/#sh.updateZoneKeyRange
https://docs.mongodb.com/manual/reference/method/sh.addShardTag/#sh.addShardTag
https://docs.mongodb.com/manual/reference/method/sh.removeShardTag/#sh.removeShardTag
https://docs.mongodb.com/manual/reference/method/sh.addTagRange/#sh.addTagRange
https://docs.mongodb.com/manual/reference/method/sh.removeTagRange/#sh.removeTagRange
https://docs.mongodb.com/manual/reference/command/balancerStart/#dbcmd.balancerStart
https://docs.mongodb.com/manual/reference/method/sh.startBalancer/#sh.startBalancer
https://docs.mongodb.com/manual/reference/command/balancerStatus/#dbcmd.balancerStatus
https://docs.mongodb.com/manual/reference/command/balancerStop/#dbcmd.balancerStop
https://docs.mongodb.com/manual/reference/method/sh.stopBalancer/#sh.stopBalancer
https://docs.mongodb.com/manual/reference/command/shardCollection/#dbcmd.shardCollection
https://docs.mongodb.com/manual/reference/method/sh.shardCollection/#sh.shardCollection
https://docs.mongodb.com/manual/reference/command/currentOp/#dbcmd.currentOp
https://docs.mongodb.com/manual/reference/method/db.currentOp/#db.currentOp
https://docs.mongodb.com/manual/reference/method/sh.getBalancerLockDetails/#sh.getBalancerLockDetails
https://docs.mongodb.com/manual/reference/method/sh.getBalancerHost/#sh.getBalancerHost
https://docs.mongodb.com/manual/reference/method/sh.status/#sh.status
https://docs.mongodb.com/manual/reference/program/mongod/
https://docs.mongodb.com/manual/reference/program/mongos/
https://docs.mongodb.com/manual/reference/program/mongodump/
https://docs.mongodb.com/manual/reference/configuration-options/
https://docs.mongodb.com/manual/reference/parameters/
https://docs.mongodb.com/manual/reference/glossary/
bitwise operators:
https://docs.mongodb.com/manual/reference/operator/query/bitsAllClear/#op._S_bitsAllClear
https://docs.mongodb.com/manual/reference/operator/query/bitsAllSet/#op._S_bitsAllSet
https://docs.mongodb.com/manual/reference/operator/query/bitsAnyClear/#op._S_bitsAnyClear
https://docs.mongodb.com/manual/reference/operator/query/bitsAnySet/#op._S_bitsAnySet
aggregation:
https://docs.mongodb.com/manual/core/aggregation-pipeline/
https://docs.mongodb.com/manual/core/aggregation-pipeline-optimization/
https://docs.mongodb.com/manual/core/aggregation-pipeline-limits/
https://docs.mongodb.com/manual/core/aggregation-pipeline-sharded-collections/
https://docs.mongodb.com/manual/reference/operator/aggregation/collStats/#pipe._S_collStats
https://docs.mongodb.com/manual/reference/operator/aggregation/project/#pipe._S_project
https://docs.mongodb.com/manual/reference/operator/aggregation/unwind/#pipe._S_unwind
https://docs.mongodb.com/manual/reference/operator/aggregation/group/#pipe._S_group
https://docs.mongodb.com/manual/reference/operator/aggregation/sample/#pipe._S_sample
https://docs.mongodb.com/manual/reference/operator/aggregation/lookup/#pipe._S_lookup
https://docs.mongodb.com/manual/reference/operator/aggregation/indexStats/#pipe._S_indexStats
https://docs.mongodb.com/manual/reference/operator/aggregation/facet/#pipe._S_facet
https://docs.mongodb.com/manual/reference/operator/aggregation/bucket/#pipe._S_bucket
https://docs.mongodb.com/manual/reference/operator/aggregation/bucketAuto/#pipe._S_bucketAuto
https://docs.mongodb.com/manual/reference/operator/aggregation/sortByCount/#pipe._S_sortByCount
https://docs.mongodb.com/manual/reference/operator/aggregation/addFields/#pipe._S_addFields
https://docs.mongodb.com/manual/reference/operator/aggregation/replaceRoot/#pipe._S_replaceRoot
https://docs.mongodb.com/manual/reference/operator/aggregation/graphLookup/#pipe._S_graphLookup
https://docs.mongodb.com/manual/reference/operator/aggregation/abs/#exp._S_abs
https://docs.mongodb.com/manual/reference/operator/aggregation/ceil/#exp._S_ceil
https://docs.mongodb.com/manual/reference/operator/aggregation/exp/#exp._S_exp
https://docs.mongodb.com/manual/reference/operator/aggregation/floor/#exp._S_floor
https://docs.mongodb.com/manual/reference/operator/aggregation/ln/#exp._S_ln
https://docs.mongodb.com/manual/reference/operator/aggregation/log/#exp._S_log
https://docs.mongodb.com/manual/reference/operator/aggregation/log10/#exp._S_log10
https://docs.mongodb.com/manual/reference/operator/aggregation/pow/#exp._S_pow
https://docs.mongodb.com/manual/reference/operator/aggregation/sqrt/#exp._S_sqrt
https://docs.mongodb.com/manual/reference/operator/aggregation/trunc/#exp._S_trunc
https://docs.mongodb.com/manual/reference/operator/aggregation/indexOfBytes/#exp._S_indexOfBytes
https://docs.mongodb.com/manual/reference/operator/aggregation/indexOfCP/#exp._S_indexOfCP
https://docs.mongodb.com/manual/reference/operator/aggregation/split/#exp._S_split
https://docs.mongodb.com/manual/reference/operator/aggregation/strLenBytes/#exp._S_strLenBytes
https://docs.mongodb.com/manual/reference/operator/aggregation/strLenCP/#exp._S_strLenCP
https://docs.mongodb.com/manual/reference/operator/aggregation/substr/#exp._S_substr
https://docs.mongodb.com/manual/reference/operator/aggregation/substrBytes/#exp._S_substrBytes
https://docs.mongodb.com/manual/reference/operator/aggregation/arrayElemAt/#exp._S_arrayElemAt
https://docs.mongodb.com/manual/reference/operator/aggregation/concatArrays/#exp._S_concatArrays
https://docs.mongodb.com/manual/reference/operator/aggregation/filter/#exp._S_filter
https://docs.mongodb.com/manual/reference/operator/aggregation/in/#exp._S_in
https://docs.mongodb.com/manual/reference/operator/aggregation/indexOfArray/#exp._S_indexOfArray
https://docs.mongodb.com/manual/reference/operator/aggregation/isArray/#exp._S_isArray
https://docs.mongodb.com/manual/reference/operator/aggregation/reduce/#exp._S_reduce
https://docs.mongodb.com/manual/reference/operator/aggregation/reverseArray/#exp._S_reverseArray
https://docs.mongodb.com/manual/reference/operator/aggregation/slice/#exp._S_slice
https://docs.mongodb.com/manual/reference/operator/aggregation/zip/#exp._S_zip
https://docs.mongodb.com/manual/reference/operator/aggregation/dateToString/#exp._S_dateToString
https://docs.mongodb.com/manual/reference/operator/aggregation/isoDayOfWeek/#exp._S_isoDayOfWeek
https://docs.mongodb.com/manual/reference/operator/aggregation/isoWeek/#exp._S_isoWeek
https://docs.mongodb.com/manual/reference/operator/aggregation/isoWeekYear/#exp._S_isoWeekYear
https://docs.mongodb.com/manual/reference/operator/aggregation/switch/#exp._S_switch
https://docs.mongodb.com/manual/reference/operator/aggregation/type/#exp._S_type
https://docs.mongodb.com/manual/reference/operator/aggregation/stdDevPop/#grp._S_stdDevPop
https://docs.mongodb.com/manual/reference/operator/aggregation/stdDevSamp/#grp._S_stdDevSamp
https://docs.mongodb.com/manual/reference/command/aggregate/#dbcmd.aggregate
https://docs.mongodb.com/manual/reference/command/group/#dbcmd.group
https://docs.mongodb.com/manual/reference/method/db.collection.group/#db.collection.group
https://docs.mongodb.com/manual/reference/limits/
https://docs.mongodb.com/manual/tutorial/iterate-a-cursor/
meta operator / cursor methods:
https://docs.mongodb.com/manual/reference/operator/query-modifier/
https://docs.mongodb.com/manual/reference/operator/meta/comment/#metaOp._S_comment
https://docs.mongodb.com/manual/reference/operator/meta/explain/#metaOp._S_explain
https://docs.mongodb.com/manual/reference/operator/meta/hint/#metaOp._S_hint
https://docs.mongodb.com/manual/reference/operator/meta/maxScan/#metaOp._S_maxScan
https://docs.mongodb.com/manual/reference/operator/meta/max/#metaOp._S_max
https://docs.mongodb.com/manual/reference/operator/meta/maxTimeMS/#metaOp._S_maxTimeMS
https://docs.mongodb.com/manual/reference/operator/meta/min/#metaOp._S_min
https://docs.mongodb.com/manual/reference/operator/meta/orderby/#metaOp._S_orderby
https://docs.mongodb.com/manual/reference/operator/meta/query/#metaOp._S_query
https://docs.mongodb.com/manual/reference/operator/meta/returnKey/#metaOp._S_returnKey
https://docs.mongodb.com/manual/reference/operator/meta/showDiskLoc/#metaOp._S_showDiskLoc
https://docs.mongodb.com/manual/reference/operator/meta/snapshot/#metaOp._S_snapshot
https://docs.mongodb.com/manual/reference/operator/meta/natural/#metaOp._S_natural
https://docs.mongodb.com/manual/reference/command/aggregate/#dbcmd.aggregate
https://docs.mongodb.com/manual/reference/method/cursor.addOption/#cursor.addOption
https://docs.mongodb.com/manual/reference/method/cursor.comment/#cursor.comment
https://docs.mongodb.com/manual/reference/method/cursor.max/#cursor.max
https://docs.mongodb.com/manual/reference/method/cursor.maxScan/#cursor.maxScan
https://docs.mongodb.com/manual/reference/method/cursor.min/#cursor.min
https://docs.mongodb.com/manual/reference/method/cursor.showRecordId/#cursor.showRecordId
https://docs.mongodb.com/manual/reference/method/cursor.tailable/#cursor.tailable
document validation:
https://docs.mongodb.com/manual/core/document-validation/
https://docs.mongodb.com/manual/core/databases-and-collections/
https://docs.mongodb.com/manual/reference/privilege-actions/
https://docs.mongodb.com/manual/reference/opertaor/aggregation/out/#pipe._S_out
https://docs.mongodb.com/manual/reference/command/aggregate/#dbcmd.aggregate
https://docs.mongodb.com/manual/reference/command/mapReduce/#dbcmd.mapReduce
https://docs.mongodb.com/manual/reference/command/findAndModify/#dbcmd.findAndModify
https://docs.mongodb.com/manual/reference/command/insert/#dbcmd.insert
https://docs.mongodb.com/manual/reference/command/update/#dbcmd.update
https://docs.mongodb.com/manual/reference/command/collMod/#dbcmd.collMod
https://docs.mongodb.com/manual/reference/command/create/#dbcmd.create
https://docs.mongodb.com/manual/reference/method/db.collection.aggregate/#db.collection.aggregate
https://docs.mongodb.com/manual/reference/method/db.collection.findAndModify/#db.collection.findAndModify
https://docs.mongodb.com/manual/reference/method/db.collection.mapReduce/#db.collection.mapReduce
https://docs.mongodb.com/manual/reference/method/db.createCollection/#db.createCollection
https://docs.mongodb.com/manual/reference/method/db.getCollectionInfos/#db.getCollectionInfos
https://docs.mongodb.com/manual/reference/program/mongorestore/
https://docs.mongodb.com/manual/reference/program/mongoimport/
collation:
https://docs.mongodb.com/manual/reference/bson-type-comparison-order/
https://docs.mongodb.com/manual/reference/collation/
https://docs.mongodb.com/manual/reference/collation-locales-defaults/
https://docs.mongodb.com/manual/reference/method/cursor.collation/#cursor.collation
https://docs.mongodb.com/manual/reference/command/aggregate/#dbcmd.aggregate
https://docs.mongodb.com/manual/reference/command/distinct/#dbcmd.distinct
https://docs.mongodb.com/manual/reference/command/delete/#dbcmd.delete
https://docs.mongodb.com/manual/reference/command/update/#dbcmd.update
https://docs.mongodb.com/manual/reference/command/create/#dbcmd.create
https://docs.mongodb.com/manual/reference/command/createIndexes/#dbcmd.createIndexes
https://docs.mongodb.com/manual/reference/method/db.collection.aggregate/#db.collection.aggregate
https://docs.mongodb.com/manual/reference/method/db.collection.createIndex/#db.collection.createIndex
https://docs.mongodb.com/manual/reference/method/db.collection.deleteOne/#db.collection.deleteOne
https://docs.mongodb.com/manual/reference/method/db.collection.deleteMany/#db.collection.deleteMany
https://docs.mongodb.com/manual/reference/method/db.collection.distinct/#db.collection.distinct
https://docs.mongodb.com/manual/reference/method/db.collection.findAndModify/#db.collection.findAndModify
https://docs.mongodb.com/manual/reference/method/db.collection.mapReduce/#db.collection.mapReduce
https://docs.mongodb.com/manual/reference/method/db.collection.remove/#db.collection.remove
https://docs.mongodb.com/manual/reference/method/db.collection.update/#db.collection.update
https://docs.mongodb.com/manual/reference/method/db.createCollection/#db.createCollection
https://docs.mongodb.com/manual/reference/method/Bulk.find.collation/#Bulk.find.collation
bulk write:
https://docs.mongodb.com/manual/reference/method/db.collection.bulkWrite/#db.collection.bulkWrite
VERSION ==> #3.0.2
GENERAL ==> #NoSQL database that uses JavaScript-like objects (BSON), based on V8 engine.
SHORT SUMMARY ==> #Goal:
# - document-oriented, close to JavaScript/JSON, schemaless
# - powerful queries
# - eleviates application logic with complex operations on search/update,
# include groupped (e.g. mapReduce), sorting, etc.
#Other use cases:
# - FIFO
# - TTL
# - geolocation search
# - text search
#Main properties:
# - optimized for speed
#Other properties:
# - BASE (not ACID) with decent durability (WAL)
# - Scaling: replica sets (read-only), sharding (write)
# - High availability: replica sets
# - Monitoring: logging, stats, alerts, debugging
# - Security: fairly ok
# - Maintainance: backups, migrations
LONG SUMMARY ==> #Design:
# - document-oriented:
# - dynamic OBJ
# - BSON: like JavaScript but binary and extra types: function, double, int,
# longlong, oid, dbref, date, timestamp, binary
# - server > databases > collections > objects
# - normalized vs denormalized
# - unique index
# - capped COLL / tailable CUR (FIFO)
# - TTL
#CRUD:
# - read:
# - &find():
# - declarative generic search
# - > >= <= < == != in nin && || ! typeof %
# - regex
# - ARR.contains(), ARR.length
# - Q$where(): imperative flexible search, using JavaScript FUNC
# - text search: tokenization, remove common words, simplist suffix stemming,
# case insensitive, "..." search, -WORD exclusion
# - geolocation search:
# - types: flat, on a sphere, haystack (points close to each other)
# - query: close to, within, intersects
# - return value manipulation:
# - projection: simple exclusion|inclusions
# - sorting
# - &aggregate():
# - operations:
# - > >= <= < == != && || ! + - * / %
# - STR.concat() STR.toLower|Upper() STR.slice() DATE.get*() DATE.format()
# - ARR.length ARR.some|any()
# Set_operations(unions,difference,intersection,equal,subset)
# - ARR -> several OBJ
# - several OBJs -> first|last|min|max|sum|avg|push|addToSet() (like "group by")
# - if|then|else
# - excluding sub-OBJs
# - operations output can be used for query, i.e. for complex search
# instead of manipulation
# - output: direct or to another collection
# - &group|count|distinct():
# - group by key
# - operations: ARR.reduce(), ARR.length, ARR.getUniqueValues()
# - &mapReduce():
# - map: group|unwind by arbitrary logic (JavaScript function)
# - reduce: like ARR.reduce()
# - create:
# - &insert()
# - create|update:
# - &update(), &save|findAndModify()
# - operations:
# - = += *= &= |= ^=
# - ARR.pop|shift() ARR.push|addToSet() ARR.removeIf()
# - new Date() min|max()
# - rename variable name
# - delete: &delete()
#Limits:
# - max 1000 OBJ_ARR.length, unless using BULK writes
# - OBJ 16MB, unless using GridFS (files, non-atomic operations)
# - max. num connections
#ACID:
# - atomicity: OBJ-level, never multi-OBJs
# - consistency/isolation:
# - write locks can yield in the middle, unless $isolated 1
# - cursors can have duplicated reads, unless $snapshot
# - durability:
# - always read uncommitted (can read a write that is received but not journaled)
# - WAL: writes are journaled, and can optionally only return success once journaled
#High availability:
# - replica sets (automatic failover using async log shipping): arbiter, passive
#Scalability:
# - replica sets (multiple read servers): hidden|read preferences (query routing)
# - sharding (multiple write servers): choose right shard key, per COLL
# (choose primary shard), restrictions
#Performance:
# - cursors: pagination, skip|limit, maxScan|maxTimeMS
# - indexes: sorting, multikey (on ARR), compound vs several, hashed (HASH(VAL)),
# sparse (no undefined)
# - BULK writes
# - space allocation
# - compression
# - workingSet should fit in RAM
# - mongoperf
# - query plans/debugging
#Security:
# - Users, roles, permissions on resources
# - Authentication: Kerberos, SSL, SASL, passwords
# - Audit log
#Maintenance:
# - backups: manual vs snapshots (can use MMS) vs mongodump, delayed replica
# - migration: export|import as JSON or CSV
# - monitoring:
# - stat commands, mongotop|mongostat, MMS (graph|text)
# - alerts (MMS)
# - logging (can use MMS), profiling (can use MMS)
# - debugging:
# - bsondump
# - mongosniff
# - server management (MMS)
#Clients:
# - Mongo shell (JavaScript)
# - Node.js driver, Mongoose
# - Robomongo, Genghisapp
# - MMS
UPGRADE ==> #Should upgrade in this order:
# - drivers
# - mongos: first disable balancer, then upgrade each mongos
# - config servers: starting with last one listed in configDB
# - mongod:
# - replica sets: starts with secondaries, then make failover to upgrade primary
#How:
# - using OS mechanics (e.g. apt-get)
# - or using d,s--upgrade
# - or MMS
#Can check upgrade minor number upgrades problems before starting with:
# - 2.4 to 2.6: DB.upgradeCheck[AllDBs]() and &&authSchemaUpgrade()
# - 2.6 to 3.0: DB.upgradeCheck[AllDBs]() and &&authSchemaUpgrade()
/=+===============================+=\
/ : : \
)==: DESIGN :==(
\ :_______________________________: /
\=+===============================+=/
SCHEMA ==> #Schemaless, i.e.:
# - columns be added|removed runtime
# - stores OBJ.VAR names for each OBJ (not only OBJ.VAL), so should not be too long
# - columns can also mix types
NORMALIZATION ==> #Can choose to either include entities references as OID or to include them as sub-OBJ.
#Is similar to normalization|denormalization tradeoffs.
#Comparison:
# - performance:
# - OID -> lower network performance: needs several round-trip to the server
# - sub-OBJ -> (mmapv1 only) lower I/O performance (one|many-to-many relationship only):
# - embedded OBJ_ARR changes over time
# - but MongoDB is faster when documents don't change size
# (needs reallocate space otherwise, which is slow)
# - ACID:
# - OID -> lower atomicity: operations are atomic at the OBJ (and sub-OBJ) level only
# - sub-OBJ -> lower consistency (many-to-many relationship only):
# - denormalization problems, since updating one entity requires updating all
# - simplicity:
# - OID -> more complex, since application needs to rebuild the different pieces together
# - sub-OBJ -> harder to represent complex relationship/hierarchical patterns
# - scalability:
# - sub-OBJ -> can hit maximum OBJ_ARR size (one|many-to-many relationship only)
#Conclusion:
# - for one-to-one relationship (except with complex relationship|hierarchical patterns),
# sub-OBJ is always better
# - for one-to-many, sub-OBJ is better as long as OBJ_ARR will not hit max OBJ_ARR size
# - for many-to-many, prefer references, unless performance is critical and application
# tries to guarentee consistency
/=+===============================+=\
/ : : \
)==: NOTATION :==(
\ :_______________________________: /
\=+===============================+=/
NOTATION ==> #This doc uses the following notations.
VAR#TYPE,... #Means { VAR,... }
CMD()#VAR #CMD(...) first OBJ argument, key VAR
#If no OBJ specified in definition, means OBJ as last argument.
VARR #Can be:
# - "VAR[.VAR2[...]]"
# - "ARR[.NUM][.VAR2[...]]": no NUM means any
VARR$ #Like VARR but NUM can also be "$", meaning:
# - the first element matching Q_OBJ, and Q_OBJ must include ARR.
# - if Q_OBJ uses Q$ne(), Q$not(), Q$nor() or Q$nin(), must be wrapped in $elemMatch
VAR$ #Same as VARR$ but NUM can *only* be "$"
VARRR #"VAR[.VAR2[...]]" or VAR: { VAR2: VAL }
AGG_EXPR #Can be:
# - any VAL.
# If STR starting with "$", must be written { "$literal": STR }
# - "$VARR"
# If VARR does not exist, no error, just undefined
# - "$$CURRENT": current OBJ
# - O$CMD(AGG_EXPR...)
# - O$literal(VAL): like VAL, but avoid syntax ambiguity to interpret it as an AGG_EXPR,
# on some edge cases
#Used with &aggregate()
COMMANDS ==> #
COMMAND(...) #Run in mongo shell
&COMMAND([VAL[, VAR#TYPE...]]) # - Mongo shell: DB.runCommand(OBJ)
# - Node.js: ~DB.command(OBJ[, OBJ2])
#Where OBJ:
# - is { COMMAND: VAL, VAR... }
# - if no VAL, means any works (usually use 1)
&&COMMAND(...) #Same but require to be in admin DB.
#Can also use:
# - Mongo shell: SH._adminCommand(OBJ[, BOOL]): like DB.runCommand(OBJ) but:
# - run in admin DB
# - if true, must connect to mongos
# - Node.js: ~DB.executeDbAdminCommand(OBJ[, OBJ2]) or ~ADMIN.command(OBJ[, OBJ2])
~COMMAND(...) #Node.js driver. When using a class, actually prepended by require("mongodb"), e.g.
#new ~MongoClient is "new (require('mongodb')).MongoClient"
[c|p]^COMMAND(...) #Mongoose driver. When using a class, actually prepended by require("mongoose")
# - c means: if not using final callback FUNC(ERROR,[A]CUR.toArray()), rreturns [A]CUR
# - p means: if not using final callback FUNC(ERROR, VAL), rreturns PROMISE, with methods:
# - fulfill(VAL), reject(ERROR), resolve(ERROR, VAL)
# - then(FUNC(VAL)[, FUNC(ERROR)])
# - end(): to use after then() if then() can throw error, so it propagates.
QQ$CMD(BOOL...) #{ $CMD: Q_OBJ_ARR }, where each Q_OBJ is transtyped to BOOL.
#Used in queries.
Q$CMD(OBJ.VAR, VAL...)... #{ VARR: { $CMD: VAL[_ARR], ... } }, used in queries.
P$CMD(OBJ.VAR, VAL...)... #{ VAR$: { $CMD: VAL[_ARR], ... } }, used in queries.
C$CMD(VAL) #Can be:
# - { $query: Q_OBJ, $CMD: VAL } instead of Q_OBJ.
# - [A]CUR._addSpecial( CMD_STR, VAL )
# - ~CUR.addQueryModifier( "$CMD", VAL ): rreturns CUR
# - ~COLL.findOne()#CMD_VAR
#Perform actions on returned cursors.
U$CMD(OBJ.VAR, VAL)... #{ $CMD: { VARR: VAL, ... } }, used with write methods.
S$CMD(OBJ, VAL) #{ $CMD: VAL }, applied to current OBJ. Used with &aggregate()
O$CMD(VAL...) #{ $CMD: AGG_EXPR[_ARR] }, used with &aggregate()
COMMAND LINE ARGUMENTS ==> #
ds--VAR #mongod|mongos --setParameter VAR=VAL
#Can also runtime:
# - &setParameter(VAR#VAL)
# - &getParameter(VAR#1)
d--VAR #mongod
s--VAR #mongos
o--VAR #mongo
dmp--VAR #mongodump
rst--VAR #mongorestore
bsn--VAR #bsondump
opl--VAR #mongooplog
imp--VAR #mongoimport
exp--VAR #mongoexport
sta--VAR #mongostat
top--VAR #mongotop
fil--VAR #mongofiles
snf--VAR #mongosniff
prf--VAR #mongoperf
mnt--VAR #mongodump, mongorestore, mongooplog, mongoimport, mongoexport, mongofiles
cli--VAR #Same as mnt + mongostat, mongotop, mongod, mongos
inout--VAR #Same as mnt + mongostat, mongotop, mongo
OTHER ==> #
cf--VAR #Specified in YAML file specified with mongod|mongos --config FILE
cn--VAR #Specified as query variables to CONN_STR
RETURN VALUE ==> # - "returns VAL": use final callback FUNC(ERROR, VAL)
# If returns nothing, callback FUNC(ERROR) can still be used.
# - "rreturns VAL": returns VAL
##Can also use MONGOOSE-Q() (version 0.0.13) instead of MONGOOSE so that if Func()
##"returns VAL", FuncQ() (e.g. MODEL.removeQ()) rreturns Q PROMISE instead
/=+===============================+=\
/ : : \
)==: BASICS :==(
\ :_______________________________: /
\=+===============================+=/
DB.runCommand({COMMAND:VAL}, ... )#Often a wrapper function VAL.COMMAND(...) exist.
#Return an OBJ, with (except if if in Mongo shell):
# - ok#1
# - ok#0, errmsg#STR, code#NUM
OBJ #Uses BSON:
# - physically stored in a compact form, "binary"
# - Mongo shell can use Object.bsonsize(OBJ)
# - use extended JSON, i.e. adds the following types:
# - FUNC[_SCOPE]:
# - _SCOPE keeps the scope (e.g. &mapReduce())
# - With Node.js:
# - cannot &insert() FUNC, unless using either:
# - ~MONGO.connect()#db.serializeFunctions true
# - ~DB.collection|createCollection()#serializeFunctions true
# - ~COLL.insert*|bulkWrite()#serializeFunctions true
# - returned as { code FUNC_STR, scope OBJ }
# - DOUBLE: def for numbers
# - INT: 32 bits, constructed with NumberInt(INT)
# - LONGLONG: 64bits
# - constructed with:
# - Mongoshell: NumberLong(LONGLONG).
# - Node.js: ~new Long(NUM, NUM2): where each NUM is 32 bits of data.
# Has many methods for calculation and conversion (see online doc)
# - can use ~MONGO.connect()#db.promoteLongs true (def) to convert to DOUBLE
# - OID:
# - Object ID, 12 bytes with:
# - 1-4: Epoch time (seconds-precise)
# - 5-7: machine ID
# - 8-9: PID
# - 10-12: counter, with random initial value
# - As opposed to UUID:
# - less uniqueness but unique as long as always < 1.6 million records/secs,
# per mongod
# - provides info about origin and ctime
# - with methods:
# - constructors (def: random) rreturning OID:
# - ObjectId([HEXA_STR])
# - ~ObjectId.createFromHexString(HEXA_STR)
# - ~ObjectId.createFromTime(EPOCHNUM)
# - new ~ObjectId([OID])
# - new ^Types.ObjectId()
# - OID.valueOf() or ~OID.toHexString(): rreturns as HEXA_STR
# - OID.toString(): returns as ObjectId("HEXA_STR")
# - OID.getTimestamp() or ~OID.getTimestamp(): rreturns date as DATE
# - ~OID.generationTime: date as EPOCH_NUM
# - ~ObjectId.isValid(OID): rreturns BOOL
# - ~OID.equals(OID2): rreturns BOOL
# - DBREF:
# - not an actual type, but a simple OBJ convention, working with some drivers
# - prefer OID, because simpler. But DBREF adds COLL+DB info.
# - Is:
# - Mongo shell: OBJ with: $id OID, $ref COLL[, $db DB]
# - Node.js: ~new DBRef('COLL', OID[, 'DB'])
# - DATE: is different from JavaScript:
# - signed 64 bits INT (negative is before Epoch),
# millisecond-precise (range: 290 million years past|future)
# - methods: like JavaScript
# - TIMESTAMP:
# - 4 bytes of Epoch time, then 4 bytes of counter for a given second
# - constructor:
# - Mongo shell: new Timestamp([NUM, NUM2])
# - Node.js: ~new Timestamp(NUM, NUM2): for each 4 bytes
# Has many methods for calculation and conversion (see online doc)
# - prefer using DATE
# - BIN: binary data, with methods:
# - new BinData(TYPE_INT, BASE64_STR)
# - ~new Binary(BUFFER|BASE64_STR, Binary.SUBTYPE_*), where * can be:
# - DEFAULT (0)
# - FUNCTION (1): FUNC type
# - BYTE_ARRAY (2)
# - UUID (4)
# - MD5 (5)
# - USER_DEFINED (128)
# - ~BIN.buffer: rreturns as BUFFER
# - ~BIN.value(): rreturns as STR
# - ~BIN.length(): rreturns NUM
# - ~BIN.read([NUM[, NUM2]]): rreturns BUFFER. NUM is position. NUM2 length.
# - ~BIN.write(STR|BUFFER[ NUM])
# - ~BIN.put(STR): single char
# - those extra types can be represented as normal JSON:
# - use an OBJ instead, e.g. { "$oid": HEXA_STR }, etc.
# - understood in input by REST interface, mongoimport, --query, but not mongo
# - output by mongoexport and REST interface
# - OBJ comparison is always exact comparison, including order.
# Can use VARR sometimes to do partial comparison.
# - null and undefined:
# - read operations:
# - (explicit) VAR: undefined -> error
# - null -> null|undefined:
# - skips sparse index unless using [A]CUR.hint(), in which case -> null only
# - Q$exists() -> undefined
# - Q$type(VAR, 0) -> undefined
# - Q$type(VAR, 10) -> null
# - write operations:
# - (explicit) VAR: undefined -> null
# - null -> null
#Limits:
# - OBJ max. 16MB (should use GridFS)
# - for INDEX: only 1MB
# - for shard key: only 512 bytes
# - when output can be written to a COLL (e.g. &aggregate() or &mapReduce()), can use
# incremental actions, i.e. querying only a specific range of input,
# then merge output COLLs
# - 100 sub-OBJs levels
# - OBJ_ARR: max length 1000 for write operations, unless using BULK
bsondump BSON_FILE #Outputs a BSON file as JSON. Used usually to understand better mongoimport output.
#Can use --pretty
#Use bsn--type "debug" for verbose.
_id #Field automatically added by write methods if omitted (according to &create() autoIndexId),
#with an index on it.
#Drivers can create it to avoid server doing it:
# - ~MONGO.connect()#db.forceServerObjectId or ~COLL.insert*()#forceServerObjectId BOOL:
# if false (def), driver adds _id when missing
# - ^SCHEMA_OPT._id BOOL: same but must be true (def)
# - ~MONGO.connect()#db.pkFactory or ~DB.collection|createCollection()#pkFactory.createPk()
# ->VAL when forceServerObjectId false, how _id are generated (def: return new ObjectId())
#By def. an OID, but can also choose:
# - UUID:
# - with helper UUID(STR), that returns it as a BIN (much smaller)
# Can change UUID() with cn--uuidRepresentation
# "standard|csharpLegacy|javaLegacy|pythonLegacy"
## - can use Mongoose plugin MONGOOSE-UUID (version 0.0.2), which takes PL_OBJ.models
## MODEL_STR_ARR (must use SCHEMA_OPT._id false). Use UUID v1 (time-based)
# - serial number:
## - can use Mongoose plugin MONGOOSE-AUTO-INCREMENT (version 3.2.0), with PL_OBJ:
## - model MODEL_STR
## - field VAR_STR (def: "_id")
## - startAt NUM (def: 0), incrementBy NUM (def: 1)
## Also creates:
## - MOBJ.nextCount(): returns NUM
## - MOBJ.resetCount(): returns nextCount()
&listCommands()
DB.listCommands() #Returns all &CMD() as OBJ|STR_ARR
help #Returns Mongo shell help
DB|RS|SH|PLANCACHE.help() #Returns all DB|RS|SH|PLANCACHE.* as STR_ARR
DB.commandHelp(CMD_STR) #Print help for &CMD()
/=+===============================+=\
/ : : \
)==: DATABASES :==(
\ :_______________________________: /
\=+===============================+=/
DB #Sets of COLL
db #Current DB
use 'DB' #Same as db = DB.getSiblingDB('DB')
&&listDatabases() #Returns:
~ADMIN.listDatabases() # - databases OBJ_ARR
# - name 'DB'
# - sizeOnDisk UINT (in bytes)
# - empty BOOL
# - totalSize NUM
DB.getName() #
~DB.databaseName #
^DB.name #Rreturns 'DB'
DB.getSiblingDB('DB')
~DB.db('DB')
^DB.useDb('DB') #Rreturns DB
&©db(fromdb#STR, todb#STR
[, fromhost#HOST[:PORT]]
[, username#STR][, key#STR]
[, slaveOk#BOOL])
DB.copyDatabase(STR, STR
[, HOST[:PORT], STR, STR]) #Copy from another host or (def) same host
&clone("DB.HOST[:PORT]")
DB.cloneDatabase("HOST[:PORT]") #Same with simpler syntax
&dropDatabase()
DB.dropDatabase()
~DB.dropDatabase() #Needs to also run &dropAllUsers|RolesFromDatabase()
/=+===============================+=\
/ : : \
)==: COLLECTIONS :==(
\ :_______________________________: /
\=+===============================+=/
COLL #Are just OBJ_ARR, but similar to SQL tables.
#'COLL' can contain "."
DB.COLL #Rreturns COLL. No need to escape "." in COLL
DB.getCollection('COLL') #Don't use DB.COLL or ^DB.collections.COLL when COLL is a MongoDB reserved word
~DB.collection('COLL'[, OBJ]) #If OBJ.strict true:
^DB.collection('COLL'[, OBJ]) # - returns COLL (instead of rreturning it)
^DB.collections.COLL # - non existing COLL produces ERROR. Otherwise, creates it.
^MODEL.collection #^DB.collection() calls createCollection('COLL', OBJ) if not existing.
&create('COLL'[, capped#BOOL] #Creates a COLL. Usually not needed since &insert() does it implicitely.
[, autoIndexId#BOOL][, size#NUM] # - capped BOOL (def: false): creates as capped COLL. See below
[, max#NUM][, flags#NUM] # - size|max: with capped COLL. See below
[, noPadding#BOOL]) # - autoIndexId BOOL (def: true): auto creates _id
DB.createCollection # - flags 0-3 (def: 1): (not with ~DB.createCollection())
('COLL'[, ...]) # - 1|3: same as powerOf2Sizes true (see below)
~DB.createCollection # - 2|3: same as noPadding true (see below)
('COLL'[, OBJ]) # - noPadding BOOL (def: false) (see below)
^SCHEMA_OPT.capped.size|max #~DB.createCollection() can use OBJ.strict BOOL (like DB.collection())
#Rreturns COLL
~COLL.options() #Returns null or { capped, autoIndexId, size, max, flags }
&cloneCollection('COLL',
from#HOST[:PORT][, query#Q_OBJ])
DB.cloneCollection(HOST[:PORT],
'COLL'[, Q_OBJ]) #
&&renameCollection
("DB.COLL", to#"DB[2].COLL[2]"
[, dropTarget#BOOL])
COLL.renameCollection
("COLL2"[, BOOL])
~DB.renameCollection('COLL',
'COLL2'[, dropTarget#BOOL])
~COLL.rename #Error if COLL2 exists unless BOOL true.
('COLL2'[, dropTarget#BOOL]) #Rreturns COLL
&listCollections([filter#Q_OBJ]) #Rreturns infos for each coll as OBJ2_ARR:
DB.getCollectionInfos() # - name STR
~DB.listCollections() # - options:
# - capped BOOL, size NUM, max NUM
# - autoIndexId BOOL
# - flags NUM
# - storageEngine STR
#&listCollections() rreturns RAW_CUR
DB.getCollectionNames() #Returns 'COLL'_ARR (including system.*)
~DB.collections() #Returns COLL_ARR (no system.*)
&drop('COLL')
~DB.dropCollection('COLL')
COLL.drop()
~COLL.drop() #Returns BOOL: false if problem, e.g. did not exist.
&collMod('COLL'[,noPadding#BOOL] #Changes some COLL properties.
[, index#OBJ]) #OBJ is { keyPattern#INDEX_STR, expireAfterSeconds#NUM }
CAPPED COLLECTIONS ==> #COLL that works as a FIFO: preserve insertion order, but must sort according to
#$natural: -1 in queries
#Created with &create() capped true, then specifying:
# - size NUM (max size in bytes, min 4KB)
# - and (optional) max NUM (max number of OBJs)
#Restrictions:
# - cannot remove OBJs
# - updates must not change OBJ size
#Tailable cursor:
# - CUR with CUR_CONF tailable and CUR_CONF awaitData
# (or ^CUR.tailable(), ^CUR.setOptions()#tailable)
# - do not use index, and wait for incoming data on a capped COLL
# - in Mongo shell, if at the end and no more coming after 2 secs, stops reading
COLL.isCapped()
~COLL.isCapped() #Returns BOOL
&convertToCapped
('COLL', size#NUM) #
&cloneCollectionAsCapped('COLL',
toCollection#'COLL2', size#NUM) #