en-US/Mdbc.dll-Help.xml

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
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
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
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
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
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
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
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
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
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
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
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
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
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
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
<?xml version="1.0" encoding="utf-8"?>
<helpItems xmlns="http://msh" schema="maml">
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Connect-Mdbc</command:name>
<maml:description>
<maml:para>Connects the client, database, and collection.</maml:para>
</maml:description>
<command:verb>Connect</command:verb>
<command:noun>Mdbc</command:noun>
</command:details>
<maml:description>
<maml:para>The cmdlet connects to the specified server and creates the variables for client, database, and collection in the current scope. By default they are $Client, $Database, and $Collection.
 
If none of the parameters ConnectionString, DatabaseName, CollectionName is specified then they are assumed to be &quot;.&quot;, &quot;test&quot;, &quot;test&quot; respectively.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Connect-Mdbc</maml:name>
<command:parameter required="false" position="0" >
<maml:name>ConnectionString</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="1" >
<maml:name>DatabaseName</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="2" >
<maml:name>CollectionName</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>ClientVariable</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>CollectionVariable</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>DatabaseVariable</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>NewCollection</maml:name>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="false" position="0" >
<maml:name>ConnectionString</maml:name>
<maml:description>
<maml:para>Connection string (see driver manuals for details):
mongodb://[username:password@]hostname[:port][/[database][?options]]
 
&quot;.&quot; is used for the default driver connection.
 
Examples:
    mongodb://localhost:27017
    mongodb://myaccount:mypass@remotehost.example.com</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="1" >
<maml:name>DatabaseName</maml:name>
<maml:description>
<maml:para>Database name. Use * in order to get available names.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="2" >
<maml:name>CollectionName</maml:name>
<maml:description>
<maml:para>Collection name. Use * in order to get available names.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>ClientVariable</maml:name>
<maml:description>
<maml:para>Name of a new variable in the current scope with the connected client. The default variable is $Client. Cmdlets with the parameter Client use it as the default value.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>CollectionVariable</maml:name>
<maml:description>
<maml:para>Name of a new variable in the current scope with the connected collection. The default variable is $Collection. Cmdlets with the parameter Collection use it as the default value.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>DatabaseVariable</maml:name>
<maml:description>
<maml:para>Name of a new variable in the current scope with the connected database. The default variable is $Database. Cmdlets with the parameter Database use it as the default value.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>NewCollection</maml:name>
<maml:description>
<maml:para>Tells to remove an existing collection before connecting the specified.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>None or database or collection names.</maml:name>
</dev:type>
</command:returnValue>
</command:returnValues>
<command:examples>
<command:example>
<maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title>
<dev:code># Connect a new collection (drop existing)
Import-Module Mdbc
Connect-Mdbc . test test -NewCollection</dev:code>
</command:example>
<command:example>
<maml:title>-------------------------- EXAMPLE 2 --------------------------</maml:title>
<dev:code># Connect the database `test`
Import-Module Mdbc
Connect-Mdbc . test
 
# Then get collections
$collection1 = Get-MdbcCollection test
$collection2 = Get-MdbcCollection process</dev:code>
</command:example>
<command:example>
<maml:title>-------------------------- EXAMPLE 3 --------------------------</maml:title>
<dev:code># Connect the client
Import-Module Mdbc
Connect-Mdbc mongodb://localhost
 
# Then get the database
$Database = Get-MdbcDatabase test</dev:code>
</command:example>
<command:example>
<maml:title>-------------------------- EXAMPLE 4 --------------------------</maml:title>
<dev:code># Connect the local and get databases
Import-Module Mdbc
Connect-Mdbc . *</dev:code>
</command:example>
<command:example>
<maml:title>-------------------------- EXAMPLE 5 --------------------------</maml:title>
<dev:code># Connect the database &apos;test&apos; and get collections
Import-Module Mdbc
Connect-Mdbc . test *</dev:code>
</command:example>
</command:examples>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Add-MdbcData</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-MdbcData</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Remove-MdbcData</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Update-MdbcData</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>MongoDB</maml:linkText>
<maml:uri>http://www.mongodb.org</maml:uri>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>New-MdbcData</command:name>
<maml:description>
<maml:para>Creates data documents.</maml:para>
</maml:description>
<command:verb>New</command:verb>
<command:noun>MdbcData</command:noun>
</command:details>
<maml:description>
<maml:para>This command is used to create Mdbc.Dictionary documents. Input objects come from the pipeline or as the parameter.
 
Created documents are used by other module commands. Note that Add-MdbcData and Export-MdbcData also have parameters Id, NewId, Convert, Property for making documents from input objects, so that in some cases intermediate use of New-MdbcData is not needed.
 
Result documents are returned as Mdbc.Dictionary objects. Mdbc.Dictionary wraps BsonDocument and implements IDictionary. It works as a hashtable where keys are case sensitive strings and values are convenient .NET types.
 
Useful members:
 
    $dictionary.Count
    $dictionary.Contains(&apos;key&apos;)
    $dictionary.Add(&apos;key&apos;, ..)
    $dictionary.Remove(&apos;key&apos;)
    $dictionary.Clear()
 
Setting values:
 
    $dictionary[&apos;key&apos;] = ..
    $dictionary.key = ..
 
Getting values:
 
    .. = $dictionary[&apos;key&apos;]
    .. = $dictionary.key
 
NOTE: On getting values, `$dictionary.key` fails if the key is missing in the strict mode. Use Contains() in order to check for missing keys. Or get values using `$dictionary[&apos;key&apos;]`, it returns nulls for missing keys.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>New-MdbcData</maml:name>
<command:parameter required="false" position="0" >
<maml:name>InputObject</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Convert</maml:name>
<command:parameterValue required="true">ScriptBlock</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Id</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Property</maml:name>
<command:parameterValue required="true">Object[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>NewId</maml:name>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="false" pipelineInput="true (ByValue)" position="0" >
<maml:name>InputObject</maml:name>
<maml:description>
<maml:para>Specifies the object to be converted to Mdbc.Dictionary. Suitable objects are dictionaries, PowerShell custom objects, and complex .NET types.
 
If the input object is omitted or null then an empty document is created.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Convert</maml:name>
<maml:description>
<maml:para>A script called on conversion of unknown data types. The variable $_ represents the unknown object. The script returns a new object suitable for conversion.
 
Examples: {} converts unknown data to nulls. {&quot;$_&quot;} converts data to strings.
 
Converters should be used sparingly, normally with unknown or varying data.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Id</maml:name>
<maml:description>
<maml:para>Specifies the _id value of result document, either literally or using a script block returning this value for the input object represented by the variable $_. The script block is used for multiple objects in the pipeline.
 
If Id is used then _id must not exist in input objects or Property.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>NewId</maml:name>
<maml:description>
<maml:para>Tells to assign _id to a new generated MongoDB.Bson.ObjectId.
 
If NewId is used then _id must not exist in input objects or Property.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Property</maml:name>
<maml:description>
<maml:para>Specifies properties or keys which values are included into documents or defines calculated fields. Missing input properties and keys are ignored.
 
If Property is omitted then types registered by Register-MdbcClassMap are serialized. Use `-Property *` in order to convert by properties instead.
 
Arguments:
 
1. Strings define property or key names of input objects. Wildcards are not supported but &quot;*&quot; may be used in order to tell &quot;convert all properties&quot;.
 
2. Hashtables @{Key=Value} define renamed and calculated fields. The key is the result document field name. The value is either a string (input object property or key) or a script block (field value calculated from the input object $_).
 
3. Hashtables @{Name=...; Expression=...} or @{Label=...; Expression=...} are similar but follow the syntax of `Select-Object -Property`.
 
See New-MdbcData examples.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<command:inputTypes>
<command:inputType>
<dev:type>
<maml:name>[Mdbc.Dictionary]</maml:name>
</dev:type>
<maml:description>
<maml:para>Objects created by New-MdbcData or obtained by Get-MdbcData or Import-MdbcData. This type is the most effective and safe as input/output of Mdbc data cmdlets.</maml:para>
</maml:description>
</command:inputType>
<command:inputType>
<dev:type>
<maml:name>[IDictionary]</maml:name>
</dev:type>
<maml:description>
<maml:para>Hashtables and other dictionaries are converted to new documents. Keys are strings used as field names. Nested collections, dictionaries, and custom objects are converted to BSON documents and collections recursively. Other values are converted to BSON values.</maml:para>
</maml:description>
</command:inputType>
<command:inputType>
<dev:type>
<maml:name>[PSObject]</maml:name>
</dev:type>
<maml:description>
<maml:para>Objects are converted to new documents. Property names are used as field names. Nested collections, dictionaries, and custom objects are converted to BSON documents and collections recursively. Other values are converted to BSON values.</maml:para>
</maml:description>
</command:inputType>
<command:inputType>
<dev:type>
<maml:name>$null</maml:name>
</dev:type>
<maml:description>
<maml:para>Null is converted to an empty document by New-MdbcData and ignored by Add-MdbcData and Export-MdbcData.</maml:para>
</maml:description>
</command:inputType>
</command:inputTypes>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>[Mdbc.Dictionary]</maml:name>
</dev:type>
<maml:description>
<maml:para>PowerShell friendly BsonDocument wrapper.</maml:para>
</maml:description>
</command:returnValue>
</command:returnValues>
<command:examples>
<command:example>
<maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title>
<dev:code># How to create empty documents
New-MdbcData
New-Object Mdbc.Dictionary
[Mdbc.Dictionary]::new() # PowerShell v5
 
# How to create documents with specified _id
New-MdbcData -Id 42
 
# How to create documents with generated _id
New-MdbcData -NewId</dev:code>
</command:example>
<command:example>
<maml:title>-------------------------- EXAMPLE 2 --------------------------</maml:title>
<dev:code># Connect collection
Import-Module Mdbc
Connect-Mdbc . test test -NewCollection
 
# Create a new document, set some data
$data = New-MdbcData -Id 12345
$data.Text = &apos;Hello world&apos;
$data.Date = Get-Date
 
# Add the document to the database
$data | Add-MdbcData
 
# Query the document from the database
$result = Get-MdbcData @{_id = 12345}
$result</dev:code>
</command:example>
<command:example>
<maml:title>-------------------------- EXAMPLE 3 --------------------------</maml:title>
<dev:code># Connect collection
Import-Module Mdbc
Connect-Mdbc . test test -NewCollection
 
# Create data from input objects and add to the database
# (Note: in similar cases Add-MdbcData may be used alone)
Get-Process mongod |
New-MdbcData -Id {$_.Id} -Property Name, WorkingSet, StartTime |
Add-MdbcData
 
# Query the data
$result = Get-MdbcData
$result</dev:code>
</command:example>
<command:example>
<maml:title>-------------------------- EXAMPLE 4 --------------------------</maml:title>
<dev:code># Example of various forms of property expressions.
# Note that ExitCode throws, so that Code will be null.
 
New-MdbcData (Get-Process -Id $Pid) -Property `
    Name, # existing property name
    Missing, # missing property name is ignored
    @{WS1 = &apos;WS&apos;}, # @{name = old name} - renamed property
    @{WS2 = {$_.WS}}, # @{name = scriptblock} - calculated field
    @{Ignored = &apos;Missing&apos;}, # renaming of a missing property is ignored
    @{n = &apos;_id&apos;; e = &apos;Id&apos;}, # @{name=...; expression=...} like Select-Object does
    @{l = &apos;Code&apos;; e = &apos;ExitCode&apos;} # @{label=...; expression=...} another like Select-Object</dev:code>
</command:example>
</command:examples>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Add-MdbcData</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Export-MdbcData</maml:linkText>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Add-MdbcData</command:name>
<maml:description>
<maml:para>Adds new documents to the database collection.</maml:para>
</maml:description>
<command:verb>Add</command:verb>
<command:noun>MdbcData</command:noun>
</command:details>
<maml:description>
<maml:para>This command adds strictly new documents to the database collection. If an input document has the field _id which already exists then the command writes an error.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Add-MdbcData</maml:name>
<command:parameter required="false" position="0" >
<maml:name>InputObject</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Collection</maml:name>
<command:parameterValue required="true">IMongoCollection`1</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Convert</maml:name>
<command:parameterValue required="true">ScriptBlock</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Id</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Property</maml:name>
<command:parameterValue required="true">Object[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Session</maml:name>
<command:parameterValue required="true">IClientSessionHandle</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>NewId</maml:name>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="false" pipelineInput="true (ByValue)" position="0" >
<maml:name>InputObject</maml:name>
<maml:description>
<maml:para>Document or a similar object, see INPUTS.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Collection</maml:name>
<maml:description>
<maml:para>Collection instance. If it is omitted then the variable $Collection is used. It is obtained by Connect-Mdbc, Get-MdbcCollection, or using the driver API.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Convert</maml:name>
<maml:description>
<maml:para>A script called on conversion of unknown data types. The variable $_ represents the unknown object. The script returns a new object suitable for conversion.
 
Examples: {} converts unknown data to nulls. {&quot;$_&quot;} converts data to strings.
 
Converters should be used sparingly, normally with unknown or varying data.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Id</maml:name>
<maml:description>
<maml:para>Specifies the _id value of result document, either literally or using a script block returning this value for the input object represented by the variable $_. The script block is used for multiple objects in the pipeline.
 
If Id is used then _id must not exist in input objects or Property.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>NewId</maml:name>
<maml:description>
<maml:para>Tells to assign _id to a new generated MongoDB.Bson.ObjectId.
 
If NewId is used then _id must not exist in input objects or Property.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Property</maml:name>
<maml:description>
<maml:para>Specifies properties or keys which values are included into documents or defines calculated fields. Missing input properties and keys are ignored.
 
If Property is omitted then types registered by Register-MdbcClassMap are serialized. Use `-Property *` in order to convert by properties instead.
 
Arguments:
 
1. Strings define property or key names of input objects. Wildcards are not supported but &quot;*&quot; may be used in order to tell &quot;convert all properties&quot;.
 
2. Hashtables @{Key=Value} define renamed and calculated fields. The key is the result document field name. The value is either a string (input object property or key) or a script block (field value calculated from the input object $_).
 
3. Hashtables @{Name=...; Expression=...} or @{Label=...; Expression=...} are similar but follow the syntax of `Select-Object -Property`.
 
See New-MdbcData examples.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Session</maml:name>
<maml:description>
<maml:para>Specifies the client session which invokes the command.
 
If it is omitted then the cmdlet is invoked in the current default session, either its own or the transaction session created by Use-MdbcTransaction.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<command:inputTypes>
<command:inputType>
<dev:type>
<maml:name>[Mdbc.Dictionary]</maml:name>
</dev:type>
<maml:description>
<maml:para>Objects created by New-MdbcData or obtained by Get-MdbcData or Import-MdbcData. This type is the most effective and safe as input/output of Mdbc data cmdlets.</maml:para>
</maml:description>
</command:inputType>
<command:inputType>
<dev:type>
<maml:name>[IDictionary]</maml:name>
</dev:type>
<maml:description>
<maml:para>Hashtables and other dictionaries are converted to new documents. Keys are strings used as field names. Nested collections, dictionaries, and custom objects are converted to BSON documents and collections recursively. Other values are converted to BSON values.</maml:para>
</maml:description>
</command:inputType>
<command:inputType>
<dev:type>
<maml:name>[PSObject]</maml:name>
</dev:type>
<maml:description>
<maml:para>Objects are converted to new documents. Property names are used as field names. Nested collections, dictionaries, and custom objects are converted to BSON documents and collections recursively. Other values are converted to BSON values.</maml:para>
</maml:description>
</command:inputType>
<command:inputType>
<dev:type>
<maml:name>$null</maml:name>
</dev:type>
<maml:description>
<maml:para>Null is converted to an empty document by New-MdbcData and ignored by Add-MdbcData and Export-MdbcData.</maml:para>
</maml:description>
</command:inputType>
</command:inputTypes>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>New-MdbcData</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Select-Object</maml:linkText>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Get-MdbcData</command:name>
<maml:description>
<maml:para>Gets data from database collections.</maml:para>
</maml:description>
<command:verb>Get</command:verb>
<command:noun>MdbcData</command:noun>
</command:details>
<maml:description>
<maml:para>This cmdlet queries the specified or default collection.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Get-MdbcData</maml:name>
<command:parameter required="false" position="0" >
<maml:name>Filter</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>As</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Collection</maml:name>
<command:parameterValue required="true">IMongoCollection`1</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>First</maml:name>
<command:parameterValue required="true">Int64</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Last</maml:name>
<command:parameterValue required="true">Int64</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Project</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Session</maml:name>
<command:parameterValue required="true">IClientSessionHandle</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Skip</maml:name>
<command:parameterValue required="true">Int64</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Sort</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Get-MdbcData</maml:name>
<command:parameter required="false" position="0" >
<maml:name>Filter</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="true" position="named" >
<maml:name>Set</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>As</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Collection</maml:name>
<command:parameterValue required="true">IMongoCollection`1</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Project</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Session</maml:name>
<command:parameterValue required="true">IClientSessionHandle</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Sort</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Add</maml:name>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>New</maml:name>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Get-MdbcData</maml:name>
<command:parameter required="false" position="0" >
<maml:name>Filter</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="true" position="named" >
<maml:name>Update</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>As</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Collection</maml:name>
<command:parameterValue required="true">IMongoCollection`1</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Project</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Session</maml:name>
<command:parameterValue required="true">IClientSessionHandle</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Sort</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Add</maml:name>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>New</maml:name>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Get-MdbcData</maml:name>
<command:parameter required="false" position="0" >
<maml:name>Filter</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="true" position="named" >
<maml:name>Remove</maml:name>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>As</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Collection</maml:name>
<command:parameterValue required="true">IMongoCollection`1</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Project</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Session</maml:name>
<command:parameterValue required="true">IClientSessionHandle</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Sort</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Get-MdbcData</maml:name>
<command:parameter required="false" position="0" >
<maml:name>Filter</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="true" position="named" >
<maml:name>Count</maml:name>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Collection</maml:name>
<command:parameterValue required="true">IMongoCollection`1</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>First</maml:name>
<command:parameterValue required="true">Int64</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Session</maml:name>
<command:parameterValue required="true">IClientSessionHandle</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Skip</maml:name>
<command:parameterValue required="true">Int64</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Get-MdbcData</maml:name>
<command:parameter required="false" position="0" >
<maml:name>Filter</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="true" position="named" >
<maml:name>Distinct</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Collection</maml:name>
<command:parameterValue required="true">IMongoCollection`1</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Session</maml:name>
<command:parameterValue required="true">IClientSessionHandle</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="false" position="0" >
<maml:name>Filter</maml:name>
<maml:description>
<maml:para>Specifies the document(s) to be processed. The argument is either JSON or similar dictionary.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Add</maml:name>
<maml:description>
<maml:para>Tells to add new documents on Replace and Update if old documents do not exist.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>As</maml:name>
<maml:description>
<maml:para>Specifies the type of output objects. The argument is either the type or full name or a special alias.
 
Key based types:
    - [Mdbc.Dictionary] (alias &quot;Default&quot;), wrapper of BsonDocument
    - [Hashtable] or other dictionaries, PowerShell native
    - [Object], same as [System.Dynamic.ExpandoObject]
    - [MongoDB.Bson.BsonDocument], driver native
 
Property based types:
    - [PSObject] (alias &quot;PS&quot;), same as [PSCustomObject]
    - Classes defined in PowerShell or .NET assemblies
 
Key based types and PSObject are schema free, they accept any result fields. Classes should match the result fields, literally or according to the custom serialization.
 
Finally, some types are case sensitive (Mdbc.Dictionary, BsonDocument) and others are not, for example all property based types in PowerShell.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Collection</maml:name>
<maml:description>
<maml:para>Collection instance. If it is omitted then the variable $Collection is used. It is obtained by Connect-Mdbc, Get-MdbcCollection, or using the driver API.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="true" position="named" >
<maml:name>Count</maml:name>
<maml:description>
<maml:para>Tells to return the number of documents matching the Filter. Note that the optional First and Skip are taken into account. For example `-Count -First 1` may be used as effective &quot;exists&quot;.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="true" position="named" >
<maml:name>Distinct</maml:name>
<maml:description>
<maml:para>Specifies the field name and tells to return its distinct values from documents matching the Filter.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>First</maml:name>
<maml:description>
<maml:para>Specifies the number of first documents to be returned. Non positive values are ignored.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Last</maml:name>
<maml:description>
<maml:para>Specifies the number of last documents to be returned. Non positive values are ignored.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>New</maml:name>
<maml:description>
<maml:para>Tells to return new documents on Replace and Update. By default old documents are returned if they exist.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Project</maml:name>
<maml:description>
<maml:para>Specifies the projection expression, i.e. fields to be retrieved. The field _id is always included unless it is explicitly excluded.
 
The special value `*` used together with `-As &lt;type&gt;` tells to infer projected fields from the type.
 
Otherwise, the argument is either JSON or similar dictionary.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="true" position="named" >
<maml:name>Remove</maml:name>
<maml:description>
<maml:para>Tells to remove and get the first document specified by Filter and Sort.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Session</maml:name>
<maml:description>
<maml:para>Specifies the client session which invokes the command.
 
If it is omitted then the cmdlet is invoked in the current default session, either its own or the transaction session created by Use-MdbcTransaction.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="true" position="named" >
<maml:name>Set</maml:name>
<maml:description>
<maml:para>Specifies the document which replaces the first document specified by Filter and Sort. The returned document depends on New and Project.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Skip</maml:name>
<maml:description>
<maml:para>Specifies the number of documents to skip from the beginning or from the end if Last is specified. Skipping is applied to results before taking First or Last. Non positive values are ignored.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Sort</maml:name>
<maml:description>
<maml:para>Specifies the sorting expression, field names and directions. The argument is either JSON or similar dictionary.
 
If two or more fields are specified then mind the order. Use JSON or ordered dictionaries, e.g. `[ordered]@{..}`.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="true" position="named" >
<maml:name>Update</maml:name>
<maml:description>
<maml:para>Specifies the update expression. The argument is JSON, similar dictionary, or array for aggregate expressions.</maml:para>
<maml:para>This parameter tells to update the first document specified by Filter and Sort. The returned document depends on New and Project.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>[Int64]</maml:name>
</dev:type>
<maml:description>
<maml:para>Number of documents, if Count is requested.</maml:para>
</maml:description>
</command:returnValue>
<command:returnValue>
<dev:type>
<maml:name>[object]</maml:name>
</dev:type>
<maml:description>
<maml:para>Field values, if Distinct is specified.</maml:para>
</maml:description>
</command:returnValue>
<command:returnValue>
<dev:type>
<maml:name>[Mdbc.Dictionary] or other types depending on As.</maml:name>
</dev:type>
<maml:description>
<maml:para>Documents, see New-MdbcData about Mdbc.Dictionary.</maml:para>
</maml:description>
</command:returnValue>
</command:returnValues>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Connect-Mdbc</maml:linkText>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Remove-MdbcData</command:name>
<maml:description>
<maml:para>Removes documents from collections.</maml:para>
</maml:description>
<command:verb>Remove</command:verb>
<command:noun>MdbcData</command:noun>
</command:details>
<maml:description>
<maml:para>This cmdlet removes the specified documents.
 
With pipeline input, documents are found by input document _id&apos;s, without using parameters Filter and Many:
 
    ... | Remove-MdbcData
 
Otherwise, documents are specified by Filter with optional Many:
 
    Remove-MdbcData [-Filter] &lt;filter&gt; [-Many]
</maml:para>
<maml:para>In order to output the result info use the switch Result.
 
Depending on operations and settings some server exceptions are caught and written as not terminating errors, i.e. processing continues.
 
Parameters ErrorAction and variables $ErrorActionPreference are used to alter error actions. See help about_CommonParameters and about_Preference_Variables.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Remove-MdbcData</maml:name>
<command:parameter required="false" position="0" >
<maml:name>Filter</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Collection</maml:name>
<command:parameterValue required="true">IMongoCollection`1</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Session</maml:name>
<command:parameterValue required="true">IClientSessionHandle</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Many</maml:name>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Result</maml:name>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="false" pipelineInput="true (ByValue)" position="0" >
<maml:name>Filter</maml:name>
<maml:description>
<maml:para>Specifies the documents to be removed. The argument is either JSON or similar dictionary. The parameter is mandatory unless documents with _id come from the pipeline. It does not accept nulls. To remove all, use an empty filter (@{}, &apos;{}&apos;) and Many.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Collection</maml:name>
<maml:description>
<maml:para>Collection instance. If it is omitted then the variable $Collection is used. It is obtained by Connect-Mdbc, Get-MdbcCollection, or using the driver API.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Many</maml:name>
<maml:description>
<maml:para>Tells to remove all matching documents. By default the first matching document is removed. The parameter is not used if the documents come from the pipeline.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Result</maml:name>
<maml:description>
<maml:para>Tells to output the operation result info.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Session</maml:name>
<maml:description>
<maml:para>Specifies the client session which invokes the command.
 
If it is omitted then the cmdlet is invoked in the current default session, either its own or the transaction session created by Use-MdbcTransaction.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>[MongoDB.Driver.DeleteResult]</maml:name>
</dev:type>
<maml:description>
<maml:para>Returned if the Result is specified. Useful members: DeletedCount.</maml:para>
</maml:description>
</command:returnValue>
</command:returnValues>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Connect-Mdbc</maml:linkText>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Set-MdbcData</command:name>
<maml:description>
<maml:para>Replaces documents in collections.</maml:para>
</maml:description>
<command:verb>Set</command:verb>
<command:noun>MdbcData</command:noun>
</command:details>
<maml:description>
<maml:para>This cmdlet replaces old documents with new documents.
 
With pipeline input, old documents are found by input document _id&apos;s and replaced with input documents, without using parameters Filter and Set:
 
    ... | Set-MdbcData
 
Otherwise, one old document is specified by Filter and the new document by Set:
 
    Set-MdbcData [-Filter] &lt;filter&gt; [-Set] &lt;new-document&gt;
</maml:para>
<maml:para>In order to output the result info use the switch Result.
 
Depending on operations and settings some server exceptions are caught and written as not terminating errors, i.e. processing continues.
 
Parameters ErrorAction and variables $ErrorActionPreference are used to alter error actions. See help about_CommonParameters and about_Preference_Variables.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Set-MdbcData</maml:name>
<command:parameter required="false" position="0" >
<maml:name>Filter</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="1" >
<maml:name>Set</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Collection</maml:name>
<command:parameterValue required="true">IMongoCollection`1</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Options</maml:name>
<command:parameterValue required="true">ReplaceOptions</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Session</maml:name>
<command:parameterValue required="true">IClientSessionHandle</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Add</maml:name>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Result</maml:name>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="false" position="0" >
<maml:name>Filter</maml:name>
<maml:description>
<maml:para>Specifies the documents to be replaced. The argument is either JSON or similar dictionary. The parameter is mandatory unless documents with _id come from the pipeline. It does not accept nulls.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" pipelineInput="true (ByValue)" position="1" >
<maml:name>Set</maml:name>
<maml:description>
<maml:para>Specifies the new document which replaces the old matching Filter. The parameter is not used if the documents come from the pipeline.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Add</maml:name>
<maml:description>
<maml:para>Tells to add the new document if the old does not exist.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Collection</maml:name>
<maml:description>
<maml:para>Collection instance. If it is omitted then the variable $Collection is used. It is obtained by Connect-Mdbc, Get-MdbcCollection, or using the driver API.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Options</maml:name>
<maml:description>
<maml:para>Extra options, see MongoDB.Driver.ReplaceOptions</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Result</maml:name>
<maml:description>
<maml:para>Tells to output the operation result info.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Session</maml:name>
<maml:description>
<maml:para>Specifies the client session which invokes the command.
 
If it is omitted then the cmdlet is invoked in the current default session, either its own or the transaction session created by Use-MdbcTransaction.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>[MongoDB.Driver.ReplaceOneResult]</maml:name>
</dev:type>
<maml:description>
<maml:para>Returned if Result is specified. Useful members: MatchedCount, ModifiedCount, UpsertedId.</maml:para>
</maml:description>
</command:returnValue>
</command:returnValues>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Connect-Mdbc</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Update-MdbcData</maml:linkText>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Update-MdbcData</command:name>
<maml:description>
<maml:para>Updates documents in collections.</maml:para>
</maml:description>
<command:verb>Update</command:verb>
<command:noun>MdbcData</command:noun>
</command:details>
<maml:description>
<maml:para>Applies the specified Update to documents matching the specified Filter.</maml:para>
<maml:para>In order to output the result info use the switch Result.
 
Depending on operations and settings some server exceptions are caught and written as not terminating errors, i.e. processing continues.
 
Parameters ErrorAction and variables $ErrorActionPreference are used to alter error actions. See help about_CommonParameters and about_Preference_Variables.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Update-MdbcData</maml:name>
<command:parameter required="false" position="0" >
<maml:name>Filter</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="true" position="1" >
<maml:name>Update</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Collection</maml:name>
<command:parameterValue required="true">IMongoCollection`1</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Options</maml:name>
<command:parameterValue required="true">UpdateOptions</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Session</maml:name>
<command:parameterValue required="true">IClientSessionHandle</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Add</maml:name>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Many</maml:name>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Result</maml:name>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="false" position="0" >
<maml:name>Filter</maml:name>
<maml:description>
<maml:para>Specifies the document(s) to be processed. The argument is either JSON or similar dictionary.</maml:para>
<maml:para>The parameter is mandatory and does not accept nulls. In order to specify all documents use an empty filter, e.g. @{}.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="true" position="1" >
<maml:name>Update</maml:name>
<maml:description>
<maml:para>Specifies the update expression. The argument is JSON, similar dictionary, or array for aggregate expressions.</maml:para>
<maml:para>The parameter is mandatory and does not accept nulls.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Add</maml:name>
<maml:description>
<maml:para>Tells to add a document based on the filter and update if nothing was updated.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Collection</maml:name>
<maml:description>
<maml:para>Collection instance. If it is omitted then the variable $Collection is used. It is obtained by Connect-Mdbc, Get-MdbcCollection, or using the driver API.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Many</maml:name>
<maml:description>
<maml:para>Tells to update all matching documents. By default the first matching document is updated.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Options</maml:name>
<maml:description>
<maml:para>Extra options, see MongoDB.Driver.UpdateOptions</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Result</maml:name>
<maml:description>
<maml:para>Tells to output the operation result info.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Session</maml:name>
<maml:description>
<maml:para>Specifies the client session which invokes the command.
 
If it is omitted then the cmdlet is invoked in the current default session, either its own or the transaction session created by Use-MdbcTransaction.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>[MongoDB.Driver.UpdateResult]</maml:name>
</dev:type>
<maml:description>
<maml:para>Returned if Result is specified. Useful members: MatchedCount, ModifiedCount, UpsertedId.</maml:para>
</maml:description>
</command:returnValue>
</command:returnValues>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Connect-Mdbc</maml:linkText>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Update-MdbcData</maml:linkText>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Add-MdbcCollection</command:name>
<maml:description>
<maml:para>Creates a new collection in the database.</maml:para>
</maml:description>
<command:verb>Add</command:verb>
<command:noun>MdbcCollection</command:noun>
</command:details>
<maml:description>
<maml:para>This cmdlet is needed for creation of collections with extra options, like capped collections. Ordinary collections do not have to be added explicitly.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Add-MdbcCollection</maml:name>
<command:parameter required="true" position="0" >
<maml:name>Name</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Database</maml:name>
<command:parameterValue required="true">IMongoDatabase</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Options</maml:name>
<command:parameterValue required="true">CreateCollectionOptions</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" position="0" >
<maml:name>Name</maml:name>
<maml:description>
<maml:para>Specifies the name of a new collection.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Database</maml:name>
<maml:description>
<maml:para>Database instance. If it is omitted then the variable $Database is used. It is obtained by Connect-Mdbc, Get-MdbcDatabase, or using the driver API.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Options</maml:name>
<maml:description>
<maml:para>Extra options, see MongoDB.Driver.CreateCollectionOptions</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Invoke-MdbcCommand</command:name>
<maml:description>
<maml:para>Invokes database commands.</maml:para>
</maml:description>
<command:verb>Invoke</command:verb>
<command:noun>MdbcCommand</command:noun>
</command:details>
<maml:description>
<maml:para>This cmdlet is useful in order to invoke commands not covered by the module. See MongoDB for available commands and syntax.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Invoke-MdbcCommand</maml:name>
<command:parameter required="true" position="0" >
<maml:name>Command</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>As</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Database</maml:name>
<command:parameterValue required="true">IMongoDatabase</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Session</maml:name>
<command:parameterValue required="true">IClientSessionHandle</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" position="0" >
<maml:name>Command</maml:name>
<maml:description>
<maml:para>Specifies the command to be invoked. The argument is JSON, ordered dictionary, Mdbc.Dictionary, one item hashtable.
 
JSON:
 
    Invoke-MdbcCommand &apos;{create: &quot;test&quot;, capped: true, size: 10485760}&apos;
 
Ordered dictionary:
 
    Invoke-MdbcCommand ([ordered]@{create=&apos;test&apos;; capped=$true; size=10mb })
 
Mdbc.Dictionary, ordered by definition:
 
    $c = New-MdbcData
    $c.create = &apos;test&apos;
    $c.capped = $true
    $c.size = 10mb
    Invoke-MdbcCommand $c</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>As</maml:name>
<maml:description>
<maml:para>Specifies the type of output objects. The argument is either the type or full name or a special alias.
 
Key based types:
    - [Mdbc.Dictionary] (alias &quot;Default&quot;), wrapper of BsonDocument
    - [Hashtable] or other dictionaries, PowerShell native
    - [Object], same as [System.Dynamic.ExpandoObject]
    - [MongoDB.Bson.BsonDocument], driver native
 
Property based types:
    - [PSObject] (alias &quot;PS&quot;), same as [PSCustomObject]
    - Classes defined in PowerShell or .NET assemblies
 
Key based types and PSObject are schema free, they accept any result fields. Classes should match the result fields, literally or according to the custom serialization.
 
Finally, some types are case sensitive (Mdbc.Dictionary, BsonDocument) and others are not, for example all property based types in PowerShell.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Database</maml:name>
<maml:description>
<maml:para>Database instance. If it is omitted then the variable $Database is used. It is obtained by Connect-Mdbc, Get-MdbcDatabase, or using the driver API.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Session</maml:name>
<maml:description>
<maml:para>Specifies the client session which invokes the command.
 
If it is omitted then the cmdlet is invoked in the current default session, either its own or the transaction session created by Use-MdbcTransaction.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>[Mdbc.Dictionary]</maml:name>
</dev:type>
<maml:description>
<maml:para>The response document wrapped by Mdbc.Dictionary.</maml:para>
</maml:description>
</command:returnValue>
<command:returnValue>
<dev:type>
<maml:name>[object]</maml:name>
</dev:type>
<maml:description>
<maml:para>Other object type depending on As.</maml:para>
</maml:description>
</command:returnValue>
</command:returnValues>
<command:examples>
<command:example>
<maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title>
<dev:code># Get the server status, one item hashtable is fine
 
Connect-Mdbc . test
Invoke-MdbcCommand @{serverStatus = 1}</dev:code>
</command:example>
<command:example>
<maml:title>-------------------------- EXAMPLE 2 --------------------------</maml:title>
<dev:code># Connect the database `test`, get statistics for the collection
# `test.test`. Mind [ordered], otherwise the command may fail:
# &quot;`scale` is unknown command&quot;.
 
Connect-Mdbc . test
Invoke-MdbcCommand ([ordered]@{collStats = &quot;test&quot;; scale = 1mb})</dev:code>
</command:example>
<command:example>
<maml:title>-------------------------- EXAMPLE 3 --------------------------</maml:title>
<dev:code># Connect the database `test` and invoke the command with
# the database `admin` specified explicitly (because the
# current is `test` and the command is admin-only)
 
Connect-Mdbc . test
Invoke-MdbcCommand @{getLog = &apos;global&apos;} -Database (Get-MdbcDatabase admin)</dev:code>
</command:example>
<command:example>
<maml:title>-------------------------- EXAMPLE 4 --------------------------</maml:title>
<dev:code># The example command creates a capped collection with maximum
# set to 5 documents, adds 10 documents, then gets all back (5
# documents are expected).
 
Connect-Mdbc . test test -NewCollection
 
$c = New-MdbcData
$c.create = &apos;test&apos;
$c.capped = $true
$c.size = 1kb
$c.max = 5
 
$null = Invoke-MdbcCommand $c
 
# add 10 documents
foreach($_ in 1..10) {Add-MdbcData @{_id = $_}}
 
# get 5 documents
Get-MdbcData</dev:code>
</command:example>
</command:examples>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>MongoDB</maml:linkText>
<maml:uri>http://www.mongodb.org</maml:uri>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Invoke-MdbcAggregate</command:name>
<maml:description>
<maml:para>Invokes aggregate operations.</maml:para>
</maml:description>
<command:verb>Invoke</command:verb>
<command:noun>MdbcAggregate</command:noun>
</command:details>
<maml:description>
<maml:para>The cmdlet invokes the aggregation pipeline for the specified or default collection.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Invoke-MdbcAggregate</maml:name>
<command:parameter required="true" position="0" >
<maml:name>Pipeline</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>As</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Collection</maml:name>
<command:parameterValue required="true">IMongoCollection`1</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Options</maml:name>
<command:parameterValue required="true">AggregateOptions</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Session</maml:name>
<command:parameterValue required="true">IClientSessionHandle</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Invoke-MdbcAggregate</maml:name>
<command:parameter required="true" position="0" >
<maml:name>Group</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>As</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Collection</maml:name>
<command:parameterValue required="true">IMongoCollection`1</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Options</maml:name>
<command:parameterValue required="true">AggregateOptions</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Session</maml:name>
<command:parameterValue required="true">IClientSessionHandle</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" position="0" >
<maml:name>Group</maml:name>
<maml:description>
<maml:para>Specifies the low ceremony aggregate pipeline of just $group. The argument is the $group expression, either JSON or similar dictionary.
 
If the expression omits the grouping _id then null is used. This form is useful for calculating $max, $min, $sum, etc. of all field values, see examples.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="true" position="0" >
<maml:name>Pipeline</maml:name>
<maml:description>
<maml:para>One or more aggregation pipeline operations represented by JSON or similar dictionaries.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>As</maml:name>
<maml:description>
<maml:para>Specifies the type of output objects. The argument is either the type or full name or a special alias.
 
Key based types:
    - [Mdbc.Dictionary] (alias &quot;Default&quot;), wrapper of BsonDocument
    - [Hashtable] or other dictionaries, PowerShell native
    - [Object], same as [System.Dynamic.ExpandoObject]
    - [MongoDB.Bson.BsonDocument], driver native
 
Property based types:
    - [PSObject] (alias &quot;PS&quot;), same as [PSCustomObject]
    - Classes defined in PowerShell or .NET assemblies
 
Key based types and PSObject are schema free, they accept any result fields. Classes should match the result fields, literally or according to the custom serialization.
 
Finally, some types are case sensitive (Mdbc.Dictionary, BsonDocument) and others are not, for example all property based types in PowerShell.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Collection</maml:name>
<maml:description>
<maml:para>Collection instance. If it is omitted then the variable $Collection is used. It is obtained by Connect-Mdbc, Get-MdbcCollection, or using the driver API.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Options</maml:name>
<maml:description>
<maml:para>Extra options, see MongoDB.Driver.AggregateOptions</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Session</maml:name>
<maml:description>
<maml:para>Specifies the client session which invokes the command.
 
If it is omitted then the cmdlet is invoked in the current default session, either its own or the transaction session created by Use-MdbcTransaction.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>[Mdbc.Dictionary]</maml:name>
</dev:type>
<maml:description>
<maml:para>Result documents wrapped by Mdbc.Dictionary.</maml:para>
</maml:description>
</command:returnValue>
<command:returnValue>
<dev:type>
<maml:name>[object]</maml:name>
</dev:type>
<maml:description>
<maml:para>Other object types depending on As.</maml:para>
</maml:description>
</command:returnValue>
</command:returnValues>
<command:examples>
<command:example>
<maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title>
<dev:code># Data: current process names and memory working sets
# Group by names, count, sum memory, get top 3 memory
 
Connect-Mdbc . test test -NewCollection
Get-Process | Add-MdbcData -Property Name, WorkingSet
 
Invoke-MdbcAggregate @(
    @{ &apos;$group&apos; = @{
        _id = &apos;$Name&apos;
        Count = @{ &apos;$sum&apos; = 1 }
        Memory = @{ &apos;$sum&apos; = &apos;$WorkingSet&apos; }
    }}
    @{ &apos;$sort&apos; = @{Memory = -1} }
    @{ &apos;$limit&apos; = 3 }
)</dev:code>
</command:example>
<command:example>
<maml:title>-------------------------- EXAMPLE 2 --------------------------</maml:title>
<dev:code># Get the minimum and maximum values of the field .price:
Invoke-MdbcAggregate -Group &apos;{min: {$min: &quot;$price&quot;}, max: {$max: &quot;$price&quot;}}&apos;
 
# Get maximum prices by categories:
Invoke-MdbcAggregate -Group &apos;{_id: &quot;$category&quot;, price: {$max: &quot;$price&quot;}}&apos;</dev:code>
</command:example>
</command:examples>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Export-MdbcData</command:name>
<maml:description>
<maml:para>Exports objects to a BSON file.</maml:para>
</maml:description>
<command:verb>Export</command:verb>
<command:noun>MdbcData</command:noun>
</command:details>
<maml:description>
<maml:para>The cmdlet writes BSON representation of input objects to the specified file. The output file has the same format as .bson files produced by mongodump.exe.
 
Cmdlets Export-MdbcData and Import-MdbcData do not need any database connection or even MongoDB installed. They are used for file based object persistence on their own.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Export-MdbcData</maml:name>
<command:parameter required="true" position="0" >
<maml:name>Path</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="1" >
<maml:name>InputObject</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Convert</maml:name>
<command:parameterValue required="true">ScriptBlock</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>FileFormat</maml:name>
<command:parameterValue required="true">FileFormat</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Id</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Property</maml:name>
<command:parameterValue required="true">Object[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Retry</maml:name>
<command:parameterValue required="true">TimeSpan[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Append</maml:name>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>NewId</maml:name>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" position="0" >
<maml:name>Path</maml:name>
<maml:description>
<maml:para>Specifies the path to the file where BSON representation of objects will be stored.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" pipelineInput="true (ByValue)" position="1" >
<maml:name>InputObject</maml:name>
<maml:description>
<maml:para>Document or a similar object, see INPUTS.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Append</maml:name>
<maml:description>
<maml:para>Tells to append data to the file if it exists.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Convert</maml:name>
<maml:description>
<maml:para>A script called on conversion of unknown data types. The variable $_ represents the unknown object. The script returns a new object suitable for conversion.
 
Examples: {} converts unknown data to nulls. {&quot;$_&quot;} converts data to strings.
 
Converters should be used sparingly, normally with unknown or varying data.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>FileFormat</maml:name>
<maml:description>
<maml:para>Specifies the data file format:
 
     Bson
         BSON format
 
     Json
         JSON format with global output mode, default is Shell
 
     JsonShell
         JSON format with output mode Shell
 
     JsonStrict
         JSON format with output mode Strict
         (obsolete, similar to CanonicalExtendedJson)
 
     JsonCanonicalExtended
         JSON format with output mode CanonicalExtendedJson
 
     JsonRelaxedExtended
         JSON format with output mode RelaxedExtendedJson
 
     Auto (default)
         The format is defined by the file extension:
         - &quot;.JSON&quot; (all caps) is for JSON Strict,
         - &quot;.json&quot; (others) is for JSON Shell,
         - other extensions are for BSON.
 
Input JSON is a sequence of objects and arrays of objects. Arrays are unrolled. Top objects and arrays are optionally separated by spaces, tabs, and new lines. Input formats Json* just mean JSON.</maml:para>
<maml:para>Values : Auto, Bson, Json, JsonShell, JsonStrict, JsonCanonicalExtended, JsonRelaxedExtended</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Id</maml:name>
<maml:description>
<maml:para>Specifies the _id value of result document, either literally or using a script block returning this value for the input object represented by the variable $_. The script block is used for multiple objects in the pipeline.
 
If Id is used then _id must not exist in input objects or Property.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>NewId</maml:name>
<maml:description>
<maml:para>Tells to assign _id to a new generated MongoDB.Bson.ObjectId.
 
If NewId is used then _id must not exist in input objects or Property.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Property</maml:name>
<maml:description>
<maml:para>Specifies properties or keys which values are included into documents or defines calculated fields. Missing input properties and keys are ignored.
 
If Property is omitted then types registered by Register-MdbcClassMap are serialized. Use `-Property *` in order to convert by properties instead.
 
Arguments:
 
1. Strings define property or key names of input objects. Wildcards are not supported but &quot;*&quot; may be used in order to tell &quot;convert all properties&quot;.
 
2. Hashtables @{Key=Value} define renamed and calculated fields. The key is the result document field name. The value is either a string (input object property or key) or a script block (field value calculated from the input object $_).
 
3. Hashtables @{Name=...; Expression=...} or @{Label=...; Expression=...} are similar but follow the syntax of `Select-Object -Property`.
 
See New-MdbcData examples.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Retry</maml:name>
<maml:description>
<maml:para>Tells to retry on failures to open the file and specifies one or two arguments. The first is the retry timeout. The second is the retry interval, the default is 50 milliseconds.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<command:inputTypes>
<command:inputType>
<dev:type>
<maml:name>[Mdbc.Dictionary]</maml:name>
</dev:type>
<maml:description>
<maml:para>Objects created by New-MdbcData or obtained by Get-MdbcData or Import-MdbcData. This type is the most effective and safe as input/output of Mdbc data cmdlets.</maml:para>
</maml:description>
</command:inputType>
<command:inputType>
<dev:type>
<maml:name>[IDictionary]</maml:name>
</dev:type>
<maml:description>
<maml:para>Hashtables and other dictionaries are converted to new documents. Keys are strings used as field names. Nested collections, dictionaries, and custom objects are converted to BSON documents and collections recursively. Other values are converted to BSON values.</maml:para>
</maml:description>
</command:inputType>
<command:inputType>
<dev:type>
<maml:name>[PSObject]</maml:name>
</dev:type>
<maml:description>
<maml:para>Objects are converted to new documents. Property names are used as field names. Nested collections, dictionaries, and custom objects are converted to BSON documents and collections recursively. Other values are converted to BSON values.</maml:para>
</maml:description>
</command:inputType>
<command:inputType>
<dev:type>
<maml:name>$null</maml:name>
</dev:type>
<maml:description>
<maml:para>Null is converted to an empty document by New-MdbcData and ignored by Add-MdbcData and Export-MdbcData.</maml:para>
</maml:description>
</command:inputType>
</command:inputTypes>
<command:examples>
<command:example>
<maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title>
<dev:code>@{ p1 = &apos;Name1&apos;; p2 = 42 }, @{ p1 = &apos;Name2&apos;; p2 = 3.14 } | Export-MdbcData test.bson
Import-MdbcData test.bson -As PS</dev:code>
</command:example>
<command:example>
<maml:title>-------------------------- EXAMPLE 2 --------------------------</maml:title>
<dev:code># &quot;Safe&quot; logging by several writers
$data | Export-MdbcData $file -Append -Retry ([TimeSpan]::FromSeconds(10))</dev:code>
</command:example>
</command:examples>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Import-MdbcData</maml:linkText>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Import-MdbcData</command:name>
<maml:description>
<maml:para>Imports data from a file.</maml:para>
</maml:description>
<command:verb>Import</command:verb>
<command:noun>MdbcData</command:noun>
</command:details>
<maml:description>
<maml:para>The cmdlet reads data from a BSON file. Such files are produced, for example, by the cmdlet Export-MdbcData or by the utility mongodump.exe.
 
Cmdlets Export-MdbcData and Import-MdbcData do not need any database connection or even MongoDB installed. They are used for file based object persistence on their own.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Import-MdbcData</maml:name>
<command:parameter required="true" position="0" >
<maml:name>Path</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>As</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>FileFormat</maml:name>
<command:parameterValue required="true">FileFormat</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" position="0" >
<maml:name>Path</maml:name>
<maml:description>
<maml:para>Specifies the path to the BSON file where objects will be restored from.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>As</maml:name>
<maml:description>
<maml:para>Specifies the type of output objects. The argument is either the type or full name or a special alias.
 
Key based types:
    - [Mdbc.Dictionary] (alias &quot;Default&quot;), wrapper of BsonDocument
    - [Hashtable] or other dictionaries, PowerShell native
    - [Object], same as [System.Dynamic.ExpandoObject]
    - [MongoDB.Bson.BsonDocument], driver native
 
Property based types:
    - [PSObject] (alias &quot;PS&quot;), same as [PSCustomObject]
    - Classes defined in PowerShell or .NET assemblies
 
Key based types and PSObject are schema free, they accept any result fields. Classes should match the result fields, literally or according to the custom serialization.
 
Finally, some types are case sensitive (Mdbc.Dictionary, BsonDocument) and others are not, for example all property based types in PowerShell.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>FileFormat</maml:name>
<maml:description>
<maml:para>Specifies the data file format:
 
     Bson
         BSON format
 
     Json
         JSON format with global output mode, default is Shell
 
     JsonShell
         JSON format with output mode Shell
 
     JsonStrict
         JSON format with output mode Strict
         (obsolete, similar to CanonicalExtendedJson)
 
     JsonCanonicalExtended
         JSON format with output mode CanonicalExtendedJson
 
     JsonRelaxedExtended
         JSON format with output mode RelaxedExtendedJson
 
     Auto (default)
         The format is defined by the file extension:
         - &quot;.JSON&quot; (all caps) is for JSON Strict,
         - &quot;.json&quot; (others) is for JSON Shell,
         - other extensions are for BSON.
 
Input JSON is a sequence of objects and arrays of objects. Arrays are unrolled. Top objects and arrays are optionally separated by spaces, tabs, and new lines. Input formats Json* just mean JSON.</maml:para>
<maml:para>Values : Auto, Bson, Json, JsonShell, JsonStrict, JsonCanonicalExtended, JsonRelaxedExtended</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>[Mdbc.Dictionary]</maml:name>
</dev:type>
<maml:description>
<maml:para>The default output type.</maml:para>
</maml:description>
</command:returnValue>
<command:returnValue>
<dev:type>
<maml:name>[object]</maml:name>
</dev:type>
<maml:description>
<maml:para>Custom type specified by the parameter As.</maml:para>
</maml:description>
</command:returnValue>
</command:returnValues>
<command:examples>
<command:example>
<maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title>
<dev:code>@{ p1 = &apos;Name1&apos;; p2 = 42 }, @{ p1 = &apos;Name2&apos;; p2 = 3.14 } | Export-MdbcData test.bson
Import-MdbcData test.bson -As PS</dev:code>
</command:example>
<command:example>
<maml:title>-------------------------- EXAMPLE 2 --------------------------</maml:title>
<dev:code># Import data produced by ConvertTo-Json (PowerShell V3)
$Host | ConvertTo-Json | Set-Content z.json
Import-MdbcData z.json</dev:code>
</command:example>
</command:examples>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Export-MdbcData</maml:linkText>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Get-MdbcDatabase</command:name>
<maml:description>
<maml:para>Gets databases.</maml:para>
</maml:description>
<command:verb>Get</command:verb>
<command:noun>MdbcDatabase</command:noun>
</command:details>
<maml:description>
<maml:para>This cmdlet gets the database instance specified by its name, existing or not. This instance may be used as the parameter Database of relevant cmdlets. Missing databases are created automatically as soon as needed.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Get-MdbcDatabase</maml:name>
<command:parameter required="false" position="0" >
<maml:name>Name</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Client</maml:name>
<command:parameterValue required="true">MongoClient</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Settings</maml:name>
<command:parameterValue required="true">MongoDatabaseSettings</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="false" position="0" >
<maml:name>Name</maml:name>
<maml:description>
<maml:para>Specifies the database name. If it is omitted then all databases are returned.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Client</maml:name>
<maml:description>
<maml:para>Client instance. If it is omitted then the variable $Client is used. It is obtained by Connect-Mdbc or using the driver API.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Settings</maml:name>
<maml:description>
<maml:para>Extra settings, see MongoDB.Driver.MongoDatabaseSettings</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>[MongoDB.Driver.IMongoDatabase]</maml:name>
</dev:type>
<maml:description>
<maml:para>Database instance.</maml:para>
</maml:description>
</command:returnValue>
</command:returnValues>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Connect-Mdbc</maml:linkText>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Remove-MdbcDatabase</command:name>
<maml:description>
<maml:para>Removes a database.</maml:para>
</maml:description>
<command:verb>Remove</command:verb>
<command:noun>MdbcDatabase</command:noun>
</command:details>
<maml:description>
<maml:para>This cmdlet removes the specified database from the client, either default (the variable $Client) or specified by the parameter Client.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Remove-MdbcDatabase</maml:name>
<command:parameter required="true" position="0" >
<maml:name>Name</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Client</maml:name>
<command:parameterValue required="true">MongoClient</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" position="0" >
<maml:name>Name</maml:name>
<maml:description>
<maml:para>Specifies the database name.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Client</maml:name>
<maml:description>
<maml:para>Client instance. If it is omitted then the variable $Client is used. It is obtained by Connect-Mdbc or using the driver API.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Connect-Mdbc</maml:linkText>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Get-MdbcCollection</command:name>
<maml:description>
<maml:para>Gets collections.</maml:para>
</maml:description>
<command:verb>Get</command:verb>
<command:noun>MdbcCollection</command:noun>
</command:details>
<maml:description>
<maml:para>This cmdlet gets the collection instance specified by its name, existing or not. This instance may be used as the parameter Collection of relevant cmdlets. Missing collections are created automatically as soon as needed.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Get-MdbcCollection</maml:name>
<command:parameter required="false" position="0" >
<maml:name>Name</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Database</maml:name>
<command:parameterValue required="true">IMongoDatabase</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Settings</maml:name>
<command:parameterValue required="true">MongoCollectionSettings</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>NewCollection</maml:name>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="false" position="0" >
<maml:name>Name</maml:name>
<maml:description>
<maml:para>Specifies the collection name. If it is omitted then all collections are returned.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Database</maml:name>
<maml:description>
<maml:para>Database instance. If it is omitted then the variable $Database is used. It is obtained by Connect-Mdbc, Get-MdbcDatabase, or using the driver API.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>NewCollection</maml:name>
<maml:description>
<maml:para>Tells to remove the existing collection.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Settings</maml:name>
<maml:description>
<maml:para>Extra settings, see MongoDB.Driver.MongoCollectionSettings</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>[MongoDB.Driver.IMongoCollection[BsonDocument]]</maml:name>
</dev:type>
<maml:description>
<maml:para>Collection instance.</maml:para>
</maml:description>
</command:returnValue>
</command:returnValues>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Connect-Mdbc</maml:linkText>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Remove-MdbcCollection</command:name>
<maml:description>
<maml:para>Removes collections.</maml:para>
</maml:description>
<command:verb>Remove</command:verb>
<command:noun>MdbcCollection</command:noun>
</command:details>
<maml:description>
<maml:para>This cmdlet removes the specified collection from the database, either default (the variable $Database) or specified by the parameter Database.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Remove-MdbcCollection</maml:name>
<command:parameter required="true" position="0" >
<maml:name>Name</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Database</maml:name>
<command:parameterValue required="true">IMongoDatabase</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" position="0" >
<maml:name>Name</maml:name>
<maml:description>
<maml:para>Specifies the collection name.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Database</maml:name>
<maml:description>
<maml:para>Database instance. If it is omitted then the variable $Database is used. It is obtained by Connect-Mdbc, Get-MdbcDatabase, or using the driver API.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Connect-Mdbc</maml:linkText>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Rename-MdbcCollection</command:name>
<maml:description>
<maml:para>Renames collections.</maml:para>
</maml:description>
<command:verb>Rename</command:verb>
<command:noun>MdbcCollection</command:noun>
</command:details>
<maml:description>
<maml:para>This cmdlet renames the specified collection in the database, either default (the variable $Database) or specified by the parameter Database.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Rename-MdbcCollection</maml:name>
<command:parameter required="true" position="0" >
<maml:name>Name</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
<command:parameter required="true" position="1" >
<maml:name>NewName</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Database</maml:name>
<command:parameterValue required="true">IMongoDatabase</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Force</maml:name>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" position="0" >
<maml:name>Name</maml:name>
<maml:description>
<maml:para>Specifies the old collection name.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="true" position="1" >
<maml:name>NewName</maml:name>
<maml:description>
<maml:para>Specifies the new collection name.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Database</maml:name>
<maml:description>
<maml:para>Database instance. If it is omitted then the variable $Database is used. It is obtained by Connect-Mdbc, Get-MdbcDatabase, or using the driver API.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Force</maml:name>
<maml:description>
<maml:para>Tells to allow renaming if the target collection exists.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Connect-Mdbc</maml:linkText>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Register-MdbcClassMap</command:name>
<maml:description>
<maml:para>Registers serialized types.</maml:para>
</maml:description>
<command:verb>Register</command:verb>
<command:noun>MdbcClassMap</command:noun>
</command:details>
<maml:description>
<maml:para>The cmdlet registers the specified type and makes it serialized by the driver. It should be called for each serialized type before the first serialization. Types cannot be unregistered, they are supposed to be either serialized or converted for the entire session.
 
If a type is already registered by the driver, for example in another assembly, the command fails unless it is called with just Type and Force parameters. The registered class map cannot be altered by other parameters.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Register-MdbcClassMap</maml:name>
<command:parameter required="true" position="0" >
<maml:name>Type</maml:name>
<command:parameterValue required="true">Type</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Discriminator</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>ExtraElementsProperty</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>IdProperty</maml:name>
<command:parameterValue required="true">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Init</maml:name>
<command:parameterValue required="true">ScriptBlock</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>DiscriminatorIsRequired</maml:name>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>IgnoreExtraElements</maml:name>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Register-MdbcClassMap</maml:name>
<command:parameter required="true" position="0" >
<maml:name>Type</maml:name>
<command:parameterValue required="true">Type</command:parameterValue>
</command:parameter>
<command:parameter required="true" position="named" >
<maml:name>Force</maml:name>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" position="0" >
<maml:name>Type</maml:name>
<maml:description>
<maml:para>Specifies the type to be treated as serialized. Use other parameters in order to tweak some serialization options in here instead of using Bson* attributes or in addition.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Discriminator</maml:name>
<maml:description>
<maml:para>Specifies the type discriminator saved as the field _t. By default, the type name is used as the discriminator.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>DiscriminatorIsRequired</maml:name>
<maml:description>
<maml:para>Tells to save the type discriminator _t. This may be useful for base classes of mixed top level documents. Derived classes inherit this attribute and save their discriminators.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>ExtraElementsProperty</maml:name>
<maml:description>
<maml:para>Specifies the property which holds elements that do not match other properties. Supported types: [Mdbc.Dictionary], [BsonDocument], [Dictionary[string, object]].</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="true" position="named" >
<maml:name>Force</maml:name>
<maml:description>
<maml:para>Tells that the type might be already registered by the driver and this is expected. The command registers the existing or auto created map. Parameters other than Type are not allowed.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>IdProperty</maml:name>
<maml:description>
<maml:para>Specifies the property mapped to the document field _id.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>IgnoreExtraElements</maml:name>
<maml:description>
<maml:para>Tells to ignore document elements that do not match the properties.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Init</maml:name>
<maml:description>
<maml:para>Specifies the script which initializes the new class map defined by $_. Other parameters are applied to the map after calling the script. Usually, the script calls `$_.AutoMap()` first.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Use-MdbcTransaction</command:name>
<maml:description>
<maml:para>Invokes the script with a transaction.</maml:para>
</maml:description>
<command:verb>Use</command:verb>
<command:noun>MdbcTransaction</command:noun>
</command:details>
<maml:description>
<maml:para>** For replicas and shards only **
 
The cmdlet starts a transaction session and invokes the specified script. The script calls data cmdlets and either succeeds or fails. The cmdlet commits or aborts the transaction accordingly.
 
The transaction session is default for cmdlets with the parameter Session. For the script the session is exposed as the automatic variable $Session.
 
Nested calls are allowed but transactions and sessions are independent. In particular, they may not see changes made in parent or nested calls.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Use-MdbcTransaction</maml:name>
<command:parameter required="true" position="0" >
<maml:name>Script</maml:name>
<command:parameterValue required="true">ScriptBlock</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Client</maml:name>
<command:parameterValue required="true">MongoClient</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" position="0" >
<maml:name>Script</maml:name>
<maml:description>
<maml:para>Specifies the script to be invoked with a transaction session.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Client</maml:name>
<maml:description>
<maml:para>Client instance. If it is omitted then the variable $Client is used. It is obtained by Connect-Mdbc or using the driver API.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>[object]</maml:name>
</dev:type>
<maml:description>
<maml:para>Output of the specified script.</maml:para>
</maml:description>
</command:returnValue>
</command:returnValues>
<command:examples>
<command:example>
<maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title>
<dev:code># add several documents using a transaction
$documents = ...
Use-MdbcTransaction {
    $documents | Add-MdbcData
}</dev:code>
</command:example>
<command:example>
<maml:title>-------------------------- EXAMPLE 2 --------------------------</maml:title>
<dev:code># move a document using a transaction
$c1 = Get-MdbcCollection MyData1
$c2 = Get-MdbcCollection MyData2
Use-MdbcTransaction {
    # get and remove from MyData1 | add to MyData2
    Get-MdbcData @{_id = 1} -Remove -Collection $c1 |
    Add-MdbcData -Collection $c2
}</dev:code>
</command:example>
</command:examples>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Watch-MdbcChange</command:name>
<maml:description>
<maml:para>Gets the cursor for watching change events.</maml:para>
</maml:description>
<command:verb>Watch</command:verb>
<command:noun>MdbcChange</command:noun>
</command:details>
<maml:description>
<maml:para>** For replicas and shards only **
 
The cmdlet returns the cursor for watching changes in the specified collection, database, or client.
 
Cursor members:
 
    MoveNext() - Moves to the next batch of documents.
    Current - Gets the current batch of documents.
    Dispose() - Disposes the cursor after use.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Watch-MdbcChange</maml:name>
<command:parameter required="false" position="0" >
<maml:name>Pipeline</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="true" position="named" >
<maml:name>Client</maml:name>
<command:parameterValue required="true">IMongoClient</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>As</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Options</maml:name>
<command:parameterValue required="true">ChangeStreamOptions</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Session</maml:name>
<command:parameterValue required="true">IClientSessionHandle</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Watch-MdbcChange</maml:name>
<command:parameter required="false" position="0" >
<maml:name>Pipeline</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="true" position="named" >
<maml:name>Collection</maml:name>
<command:parameterValue required="true">IMongoCollection`1</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>As</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Options</maml:name>
<command:parameterValue required="true">ChangeStreamOptions</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Session</maml:name>
<command:parameterValue required="true">IClientSessionHandle</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Watch-MdbcChange</maml:name>
<command:parameter required="false" position="0" >
<maml:name>Pipeline</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="true" position="named" >
<maml:name>Database</maml:name>
<command:parameterValue required="true">IMongoDatabase</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>As</maml:name>
<command:parameterValue required="true">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Options</maml:name>
<command:parameterValue required="true">ChangeStreamOptions</command:parameterValue>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Session</maml:name>
<command:parameterValue required="true">IClientSessionHandle</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="false" position="0" >
<maml:name>Pipeline</maml:name>
<maml:description>
<maml:para>One or more aggregation pipeline operations represented by JSON or similar dictionaries.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>As</maml:name>
<maml:description>
<maml:para>Specifies the type of output objects. The argument is either the type or full name or a special alias.
 
Key based types:
    - [Mdbc.Dictionary] (alias &quot;Default&quot;), wrapper of BsonDocument
    - [Hashtable] or other dictionaries, PowerShell native
    - [Object], same as [System.Dynamic.ExpandoObject]
    - [MongoDB.Bson.BsonDocument], driver native
 
Property based types:
    - [PSObject] (alias &quot;PS&quot;), same as [PSCustomObject]
    - Classes defined in PowerShell or .NET assemblies
 
Key based types and PSObject are schema free, they accept any result fields. Classes should match the result fields, literally or according to the custom serialization.
 
Finally, some types are case sensitive (Mdbc.Dictionary, BsonDocument) and others are not, for example all property based types in PowerShell.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="true" position="named" >
<maml:name>Client</maml:name>
<maml:description>
<maml:para>Specifies the client and tells to watch its changes.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="true" position="named" >
<maml:name>Collection</maml:name>
<maml:description>
<maml:para>Specifies the collection and tells to watch its changes.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="true" position="named" >
<maml:name>Database</maml:name>
<maml:description>
<maml:para>Specifies the database and tells to watch its changes.</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Options</maml:name>
<maml:description>
<maml:para>Extra options, see MongoDB.Driver.ChangeStreamOptions</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" position="named" >
<maml:name>Session</maml:name>
<maml:description>
<maml:para>Specifies the client session which invokes the command.
 
If it is omitted then the cmdlet is invoked in the current default session, either its own or the transaction session created by Use-MdbcTransaction.</maml:para>
</maml:description>
</command:parameter>
</command:parameters>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>[MongoDB.Driver.IAsyncCursor[object]]</maml:name>
</dev:type>
<maml:description>
<maml:para>Cursor of documents describing changes.</maml:para>
</maml:description>
</command:returnValue>
</command:returnValues>
<command:examples>
<command:example>
<maml:title>-------------------------- EXAMPLE 1 --------------------------</maml:title>
<dev:code># get a new collection and watch its changes
Connect-Mdbc -NewCollection
$watch = Watch-MdbcChange -Collection $Collection
try {
    # the first MoveNext &quot;gets it ready&quot;
    $null = $watch.MoveNext()
 
    # add and update some data
    @{_id = &apos;count&apos;; value = 0} | Add-MdbcData
    Update-MdbcData @{_id = &apos;count&apos;} @{&apos;$inc&apos; = @{value = 1}}
 
    # get two documents about insert and update
    if ($watch.MoveNext()) {
        foreach($change in $watch.Current) {
            &quot;$change&quot;
        }
    }
}
finally {
    # dispose after use
    $watch.Dispose()
}</dev:code>
</command:example>
</command:examples>
</command:command>
</helpItems>