This repository has been archived by the owner on Feb 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathreql_docs.ts
2383 lines (2383 loc) · 107 KB
/
reql_docs.ts
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
// The contents of reql_docs were generated by _scripts/dataexplorer.py from the rethinkdb documentation in http://github.com/rethinkdb/docs
// hash: "c69c9c14f6519b55d1f80bf91cd4e4dbf2fabcc3"
export default {
"api/javascript/add/": {
"body": "value.add(value[, value, ...]) → valuetime.add(number[, number, ...]) → time",
"description": "<p>Sum two or more numbers, or concatenate two or more strings or arrays.</p>",
"example": "<p><strong>Example:</strong> It's as easy as 2 + 2 = 4.</p>\n<pre><code>r.expr(2).add(2).run(conn, callback)\n</code></pre>",
"io": [
[
"number",
"number"
],
[
"string",
"string"
],
[
"array",
"array"
],
[
"time",
"time"
],
[
"time",
"number"
]
],
"name": "add",
"url": "add"
},
"api/javascript/and/": {
"body": "bool.and([bool, bool, ...]) → boolr.and([bool, bool, ...]) → bool",
"description": "<p>Compute the logical \"and\" of one or more values.</p>",
"example": "<p><strong>Example:</strong> Return whether both <code>a</code> and <code>b</code> evaluate to true.</p>\n<pre><code>var a = true, b = false;\nr.expr(a).and(b).run(conn, callback);\n// result passed to callback\nfalse\n</code></pre>",
"io": [
[
"bool",
"bool"
]
],
"name": "and",
"url": "and"
},
"api/javascript/append/": {
"body": "array.append(value) → array",
"description": "<p>Append a value to an array.</p>",
"example": "<p><strong>Example:</strong> Retrieve Iron Man's equipment list with the addition of some new boots.</p>\n<pre><code>r.table('marvel').get('IronMan')('equipment').append('newBoots').run(conn, callback)\n</code></pre>",
"io": [
[
"array",
"array"
]
],
"name": "append",
"url": "append"
},
"api/javascript/args/": {
"body": "r.args(array) → special",
"description": "<p><code>r.args</code> is a special term that's used to splice an array of arguments\ninto another term. This is useful when you want to call a variadic\nterm such as <code>getAll</code> with a set of arguments produced at runtime.</p>\n<p>This is analogous to using <strong>apply</strong> in JavaScript.</p>",
"example": "<p><strong>Example:</strong> Get Alice and Bob from the table <code>people</code>.</p>\n<pre><code>r.table('people').getAll('Alice', 'Bob').run(conn, callback)\n// or\nr.table('people').getAll(r.args(['Alice', 'Bob'])).run(conn, callback)\n</code></pre>",
"io": [
[
"r",
"special"
]
],
"name": "args",
"url": "args"
},
"api/javascript/avg/": {
"body": "sequence.avg([field | function]) → number",
"description": "<p>Averages all the elements of a sequence. If called with a field name,\naverages all the values of that field in the sequence, skipping\nelements of the sequence that lack that field. If called with a\nfunction, calls that function on every element of the sequence and\naverages the results, skipping elements of the sequence where that\nfunction returns <code>null</code> or a non-existence error.</p>",
"example": "<p><strong>Example:</strong> What's the average of 3, 5, and 7?</p>\n<pre><code>r.expr([3, 5, 7]).avg().run(conn, callback)\n</code></pre>",
"io": [
[
"sequence",
"number"
]
],
"name": "avg",
"url": "avg"
},
"api/javascript/between/": {
"body": "table.between(lowerKey, upperKey[, options]) → table_slicetable_slice.between(lowerKey, upperKey[, options]) → table_slice",
"description": "<p>Get all documents between two keys. Accepts three optional arguments: <code>index</code>,\n<code>left_bound</code>, and <code>right_bound</code>. If <code>index</code> is set to the name of a secondary index,\n<code>between</code> will return all documents where that index's value is in the specified range\n(it uses the primary key by default). <code>left_bound</code> or <code>right_bound</code> may be set to <code>open</code>\nor <code>closed</code> to indicate whether or not to include that endpoint of the range (by default,\n<code>left_bound</code> is closed and <code>right_bound</code> is open).</p>",
"example": "<p><strong>Example:</strong> Find all users with primary key >= 10 and < 20 (a normal half-open interval).</p>\n<pre><code>r.table('marvel').between(10, 20).run(conn, callback)\n</code></pre>",
"io": [
[
"table",
"table_slice"
]
],
"name": "between",
"url": "between"
},
"api/javascript/binary/": {
"body": "r.binary(data) → binary",
"description": "<p>Encapsulate binary data within a query.</p>",
"example": "<p><strong>Example:</strong> Save an avatar image to a existing user record.</p>\n<pre><code>var fs = require('fs');\nfs.readFile('./defaultAvatar.png', function (err, avatarImage) {\n if (err) {\n // Handle error\n }\n else {\n r.table('users').get(100).update({\n avatar: avatarImage\n })\n }\n});\n</code></pre>",
"io": [
[
"r",
"binary"
]
],
"name": "binary",
"url": "binary"
},
"api/javascript/bracket/": {
"body": "sequence(attr) → sequencesingleSelection(attr) → valueobject(attr) → valuearray(index) → value",
"description": "<p>Get a single field from an object or a single element from a sequence.</p>",
"example": "<p><strong>Example:</strong> What was Iron Man's first appearance in a comic?</p>\n<pre><code>r.table('marvel').get('IronMan')('firstAppearance').run(conn, callback)\n</code></pre>",
"io": [
[
"sequence",
"sequence"
],
[
"singleSelection",
"value"
],
[
"object",
"value"
]
],
"name": "() (bracket)",
"url": "bracket"
},
"api/javascript/branch/": {
"body": "r.branch(test, true_action[, test2, else_action, ...], false_action) → any",
"description": "<p>Perform a branching conditional equivalent to <code>if-then-else</code>.</p>\n<p>The <code>branch</code> command takes 2n+1 arguments: pairs of conditional expressions and commands to be executed if the conditionals return any value but <code>false</code> or <code>null</code> (i.e., \"truthy\" values), with a final \"else\" command to be evaluated if all of the conditionals are <code>false</code> or <code>null</code>.</p>",
"example": "<p><strong>Example:</strong> Test the value of x.</p>\n<pre><code>var x = 10;\nr.branch(r.expr(x).gt(5), 'big', 'small').run(conn, callback);\n// Result passed to callback\n\"big\"\n</code></pre>",
"io": [
[
"r",
"any"
]
],
"name": "branch",
"url": "branch"
},
"api/javascript/ceil/": {
"body": "r.ceil(number) → numbernumber.ceil() → number",
"description": "<p>Rounds the given value up, returning the smallest integer value greater than or equal to the given value (the value's ceiling).</p>",
"example": "<p><strong>Example:</strong> Return the ceiling of 12.345.</p>\n<pre><code>> r.ceil(12.345).run(conn, callback);\n\n13.0\n</code></pre>",
"io": [
[
"number",
"number"
]
],
"name": "ceil",
"url": "ceil"
},
"api/javascript/change_at/": {
"body": "array.changeAt(index, value) → array",
"description": "<p>Change a value in an array at a given index. Returns the modified array.</p>",
"example": "<p><strong>Example:</strong> Bruce Banner hulks out.</p>\n<pre><code>r.expr([\"Iron Man\", \"Bruce\", \"Spider-Man\"]).changeAt(1, \"Hulk\").run(conn, callback)\n</code></pre>",
"io": [
[
"array",
"array"
]
],
"name": "changeAt",
"url": "change_at"
},
"api/javascript/changes/": {
"body": "stream.changes([options]) → streamsingleSelection.changes([options]) → stream",
"description": "<p>Return a changefeed, an infinite stream of objects representing changes to a query. A changefeed may return changes to a table or an individual document (a \"point\" changefeed), and document transformation commands such as <code>filter</code> or <code>map</code> may be used before the <code>changes</code> command to affect the output.</p>",
"example": "<p><strong>Example:</strong> Subscribe to the changes on a table.</p>\n<pre><code>r.table('games').changes().run(conn, function(err, cursor) {\n cursor.each(console.log)\n})\n</code></pre>",
"io": [
[
"stream",
"stream"
],
[
"singleSelection",
"stream"
]
],
"name": "changes",
"url": "changes"
},
"api/javascript/circle/": {
"body": "r.circle([longitude, latitude], radius[, {numVertices: 32, geoSystem: 'WGS84', unit: 'm', fill: true}]) → geometryr.circle(point, radius[, {numVertices: 32, geoSystem: 'WGS84', unit: 'm', fill: true}]) → geometry",
"description": "<p>Construct a circular line or polygon. A circle in RethinkDB is a polygon or line <em>approximating</em> a circle of a given radius around a given center, consisting of a specified number of vertices (default 32).</p>",
"example": "<p><strong>Example:</strong> Define a circle.</p>\n<pre><code>r.table('geo').insert({\n id: 300,\n name: 'Hayes Valley',\n neighborhood: r.circle([-122.423246,37.779388], 1000)\n}).run(conn, callback);\n</code></pre>",
"io": [
[
"r",
"geometry"
]
],
"name": "circle",
"url": "circle"
},
"api/javascript/close-cursor/": {
"body": "cursor.close()",
"description": "<p>Close a cursor. Closing a cursor cancels the corresponding query and frees the memory\nassociated with the open request.</p>",
"example": "<p><strong>Example:</strong> Close a cursor.</p>\n<pre><code>cursor.close()\n</code></pre>",
"io": [
[
"cursor",
"undefined"
]
],
"name": "close",
"url": "close-cursor"
},
"api/javascript/close/": {
"body": "conn.close([{noreplyWait: true}, ]callback)conn.close([{noreplyWait: true}]) → promise",
"description": "<p>Close an open connection.</p>\n<p>If no callback is provided, a promise will be returned.</p>",
"example": "<p><strong>Example:</strong> Close an open connection, waiting for noreply writes to finish.</p>\n<pre><code>conn.close(function(err) { if (err) throw err; })\n</code></pre>",
"io": [
[
"connection",
"undefined"
]
],
"name": "close",
"url": "close"
},
"api/javascript/coerce_to/": {
"body": "sequence.coerceTo('array') → arrayvalue.coerceTo('string') → stringstring.coerceTo('number') → numberarray.coerceTo('object') → objectsequence.coerceTo('object') → objectobject.coerceTo('array') → arraybinary.coerceTo('string') → stringstring.coerceTo('binary') → binary",
"description": "<p>Convert a value of one type into another.</p>",
"example": "<p><strong>Example:</strong> Coerce a stream to an array.</p>\n<pre><code>r.table('posts').map(function (post) {\n post.merge({ comments: r.table('comments').getAll(post('id'), {index: 'postId'}).coerceTo('array')});\n}).run(conn, callback)\n</code></pre>",
"io": [
[
"sequence",
"array"
],
[
"value",
"string"
],
[
"array",
"object"
],
[
"object",
"array"
],
[
"binary",
"string"
],
[
"string",
"binary"
]
],
"name": "coerceTo",
"url": "coerce_to"
},
"api/javascript/concat_map/": {
"body": "stream.concatMap(function) → streamarray.concatMap(function) → array",
"description": "<p>Concatenate one or more elements into a single sequence using a mapping function.</p>",
"example": "<p><strong>Example:</strong> Construct a sequence of all monsters defeated by Marvel heroes. The field \"defeatedMonsters\" is an array of one or more monster names.</p>\n<pre><code>r.table('marvel').concatMap(function(hero) {\n return hero('defeatedMonsters')\n}).run(conn, callback)\n</code></pre>",
"io": [
[
"sequence",
"stream"
],
[
"array",
"array"
]
],
"name": "concatMap",
"url": "concat_map"
},
"api/javascript/config/": {
"body": "table.config() → selection<object>database.config() → selection<object>",
"description": "<p>Query (read and/or update) the configurations for individual tables or databases.</p>",
"example": "<p><strong>Example:</strong> Get the configuration for the <code>users</code> table.</p>\n<pre><code>> r.table('users').config().run(conn, callback);\n</code></pre>",
"io": [
[
"table",
"singleSelection"
],
[
"database",
"singleSelection"
]
],
"name": "config",
"url": "config"
},
"api/javascript/connect/": {
"body": "r.connect(options, callback)r.connect(host, callback)r.connect(options) → promiser.connect(host) → promise",
"description": "<p>Create a new connection to the database server.</p>",
"example": "<p><strong>Example:</strong> Open a connection using the default host and port, specifying the default database.</p>\n<pre><code>r.connect({\n db: 'marvel'\n}, function(err, conn) {\n // ...\n});\n</code></pre>\n<p>If no callback is provided, a promise will be returned.</p>\n<pre><code>var promise = r.connect({db: 'marvel'});\n</code></pre>",
"io": [
[
"r",
"undefined"
]
],
"name": "connect",
"url": "connect"
},
"api/javascript/contains/": {
"body": "sequence.contains([value | predicate_function, ...]) → bool",
"description": "<p>Returns whether or not a sequence contains all the specified values, or if functions are\nprovided instead, returns whether or not a sequence contains values matching all the\nspecified functions.</p>",
"example": "<p><strong>Example:</strong> Has Iron Man ever fought Superman?</p>\n<pre><code>r.table('marvel').get('ironman')('opponents').contains('superman').run(conn, callback)\n</code></pre>",
"io": [
[
"sequence",
"bool"
]
],
"name": "contains",
"url": "contains"
},
"api/javascript/count/": {
"body": "sequence.count([value | predicate_function]) → numberbinary.count() → number",
"description": "<p>Count the number of elements in the sequence. With a single argument, count the number\nof elements equal to it. If the argument is a function, it is equivalent to calling\nfilter before count.</p>",
"example": "<p><strong>Example:</strong> Just how many super heroes are there?</p>\n<pre><code>r.table('marvel').count().add(r.table('dc').count()).run(conn, callback)\n</code></pre>",
"io": [
[
"sequence",
"number"
],
[
"binary",
"number"
]
],
"name": "count",
"url": "count"
},
"api/javascript/date/": {
"body": "time.date() → time",
"description": "<p>Return a new time object only based on the day, month and year (ie. the same day at 00:00).</p>",
"example": "<p><strong>Example:</strong> Retrieve all the users whose birthday is today</p>\n<pre><code>r.table(\"users\").filter(function(user) {\n return user(\"birthdate\").date().eq(r.now().date())\n}).run(conn, callback)\n</code></pre>",
"io": [
[
"time",
"time"
]
],
"name": "date",
"url": "date"
},
"api/javascript/day/": {
"body": "time.day() → number",
"description": "<p>Return the day of a time object as a number between 1 and 31.</p>",
"example": "<p><strong>Example:</strong> Return the users born on the 24th of any month.</p>\n<pre><code>r.table(\"users\").filter(\n r.row(\"birthdate\").day().eq(24)\n).run(conn, callback)\n</code></pre>",
"io": [
[
"time",
"number"
]
],
"name": "day",
"url": "day"
},
"api/javascript/day_of_week/": {
"body": "time.dayOfWeek() → number",
"description": "<p>Return the day of week of a time object as a number between 1 and 7 (following ISO 8601 standard). For your convenience, the terms r.monday, r.tuesday etc. are defined and map to the appropriate integer.</p>",
"example": "<p><strong>Example:</strong> Return today's day of week.</p>\n<pre><code>r.now().dayOfWeek().run(conn, callback)\n</code></pre>",
"io": [
[
"time",
"number"
]
],
"name": "dayOfWeek",
"url": "day_of_week"
},
"api/javascript/day_of_year/": {
"body": "time.dayOfYear() → number",
"description": "<p>Return the day of the year of a time object as a number between 1 and 366 (following ISO 8601 standard).</p>",
"example": "<p><strong>Example:</strong> Retrieve all the users who were born the first day of a year.</p>\n<pre><code>r.table(\"users\").filter(\n r.row(\"birthdate\").dayOfYear().eq(1)\n)\n</code></pre>",
"io": [
[
"time",
"number"
]
],
"name": "dayOfYear",
"url": "day_of_year"
},
"api/javascript/db/": {
"body": "r.db(dbName) → db",
"description": "<p>Reference a database.</p>",
"example": "<p><strong>Example:</strong> Explicitly specify a database for a query.</p>\n<pre><code>r.db('heroes').table('marvel').run(conn, callback)\n</code></pre>",
"io": [
[
"r",
"db"
]
],
"name": "db",
"url": "db"
},
"api/javascript/db_create/": {
"body": "r.dbCreate(dbName) → object",
"description": "<p>Create a database. A RethinkDB database is a collection of tables, similar to\nrelational databases.</p>\n<p>If successful, the operation returns an object: <code>{created: 1}</code>. If a database with the\nsame name already exists the operation throws <code>ReqlRuntimeError</code>.</p>\n<p>Note: that you can only use alphanumeric characters and underscores for the database name.</p>",
"example": "<p><strong>Example:</strong> Create a database named 'superheroes'.</p>\n<pre><code>r.dbCreate('superheroes').run(conn, callback)\n</code></pre>",
"io": [
[
"r",
"object"
]
],
"name": "dbCreate",
"url": "db_create"
},
"api/javascript/db_drop/": {
"body": "r.dbDrop(dbName) → object",
"description": "<p>Drop a database. The database, all its tables, and corresponding data will be deleted.</p>\n<p>If successful, the operation returns the object <code>{dropped: 1}</code>. If the specified database\ndoesn't exist a <code>ReqlRuntimeError</code> is thrown.</p>",
"example": "<p><strong>Example:</strong> Drop a database named 'superheroes'.</p>\n<pre><code>r.dbDrop('superheroes').run(conn, callback)\n</code></pre>",
"io": [
[
"r",
"object"
]
],
"name": "dbDrop",
"url": "db_drop"
},
"api/javascript/db_list/": {
"body": "r.dbList() → array",
"description": "<p>List all database names in the system. The result is a list of strings.</p>",
"example": "<p><strong>Example:</strong> List all databases.</p>\n<pre><code>r.dbList().run(conn, callback)\n</code></pre>",
"io": [
[
"r",
"array"
]
],
"name": "dbList",
"url": "db_list"
},
"api/javascript/default/": {
"body": "value.default(default_value | function) → anysequence.default(default_value | function) → any",
"description": "<p>Provide a default value in case of non-existence errors. The <code>default</code> command evaluates its first argument (the value it's chained to). If that argument returns <code>null</code> or a non-existence error is thrown in evaluation, then <code>default</code> returns its second argument. The second argument is usually a default value, but it can be a function that returns a value.</p>",
"example": "<p><strong>Example:</strong> Retrieve the titles and authors of the table <code>posts</code>.\nIn the case where the author field is missing or <code>null</code>, we want to retrieve the string\n<code>Anonymous</code>.</p>\n<pre><code>r.table(\"posts\").map(function (post) {\n return {\n title: post(\"title\"),\n author: post(\"author\").default(\"Anonymous\")\n }\n}).run(conn, callback);\n</code></pre>",
"io": [
[
"value",
"any"
],
[
"sequence",
"any"
]
],
"name": "default",
"url": "default"
},
"api/javascript/delete/": {
"body": "table.delete([{durability: \"hard\", returnChanges: false}])→ objectselection.delete([{durability: \"hard\", returnChanges: false}])→ objectsingleSelection.delete([{durability: \"hard\", returnChanges: false}])→ object",
"description": "<p>Delete one or more documents from a table.</p>",
"example": "<p><strong>Example:</strong> Delete a single document from the table <code>comments</code>.</p>\n<pre><code>r.table(\"comments\").get(\"7eab9e63-73f1-4f33-8ce4-95cbea626f59\").delete().run(conn, callback)\n</code></pre>",
"io": [
[
"table",
"object"
],
[
"selection",
"object"
],
[
"singleSelection",
"object"
]
],
"name": "delete",
"url": "delete"
},
"api/javascript/delete_at/": {
"body": "array.deleteAt(index [,endIndex]) → array",
"description": "<p>Remove one or more elements from an array at a given index. Returns the modified array.</p>",
"example": "<p><strong>Example:</strong> Delete the second element of an array.</p>\n<pre><code>> r(['a','b','c','d','e','f']).deleteAt(1).run(conn, callback)\n// result passed to callback\n['a', 'c', 'd', 'e', 'f']\n</code></pre>",
"io": [
[
"array",
"array"
]
],
"name": "deleteAt",
"url": "delete_at"
},
"api/javascript/difference/": {
"body": "array.difference(array) → array",
"description": "<p>Remove the elements of one array from another array.</p>",
"example": "<p><strong>Example:</strong> Retrieve Iron Man's equipment list without boots.</p>\n<pre><code>r.table('marvel').get('IronMan')('equipment').difference(['Boots']).run(conn, callback)\n</code></pre>",
"io": [
[
"array",
"array"
]
],
"name": "difference",
"url": "difference"
},
"api/javascript/distance/": {
"body": "geometry.distance(geometry[, {geoSystem: 'WGS84', unit: 'm'}]) → numberr.distance(geometry, geometry[, {geoSystem: 'WGS84', unit: 'm'}]) → number",
"description": "<p>Compute the distance between a point and another geometry object. At least one of the geometry objects specified must be a point.</p>",
"example": "<p><strong>Example:</strong> Compute the distance between two points on the Earth in kilometers.</p>\n<pre><code>var point1 = r.point(-122.423246,37.779388);\nvar point2 = r.point(-117.220406,32.719464);\nr.distance(point1, point2, {unit: 'km'}).run(conn, callback);\n// result returned to callback \n734.1252496021841\n</code></pre>",
"io": [
[
"geometry",
"number"
]
],
"name": "distance",
"url": "distance"
},
"api/javascript/distinct/": {
"body": "sequence.distinct() → arraytable.distinct([{index: <indexname>}]) → stream",
"description": "<p>Remove duplicate elements from the sequence.</p>",
"example": "<p><strong>Example:</strong> Which unique villains have been vanquished by marvel heroes?</p>\n<pre><code>r.table('marvel').concatMap(function(hero) {\n return hero('villainList')\n}).distinct().run(conn, callback)\n</code></pre>",
"io": [
[
"sequence",
"array"
],
[
"table",
"stream"
]
],
"name": "distinct",
"url": "distinct"
},
"api/javascript/div/": {
"body": "number.div(number[, number ...]) → number",
"description": "<p>Divide two numbers.</p>",
"example": "<p><strong>Example:</strong> It's as easy as 2 / 2 = 1.</p>\n<pre><code>r.expr(2).div(2).run(conn, callback)\n</code></pre>",
"io": [
[
"number",
"number"
]
],
"name": "div",
"url": "div"
},
"api/javascript/do/": {
"body": "any.do(function) → anyr.do([args]*, function) → anyany.do(expr) → anyr.do([args]*, expr) → any",
"description": "<p>Call an anonymous function using return values from other ReQL commands or queries as arguments.</p>\n<p><strong>Example:</strong> Compute a golfer's net score for a game.</p>\n<p><code>js\nr.table('players').get('f19b5f16-ef14-468f-bd48-e194761df255').do(\n function (player) {\n return player('gross_score').sub(player('course_handicap'));\n }\n).run(conn, callback);</code></p>",
"example": "",
"io": [
[
"any",
"any"
]
],
"name": "do",
"url": "do"
},
"api/javascript/downcase/": {
"body": "string.downcase() → string",
"description": "<p>Lowercases a string.</p>",
"example": "<p><strong>Example:</strong></p>\n<pre><code>r.expr(\"Sentence about LaTeX.\").downcase().run(conn, callback)\n</code></pre>",
"io": [
[
"string",
"string"
]
],
"name": "downcase",
"url": "downcase"
},
"api/javascript/during/": {
"body": "time.during(startTime, endTime[, options]) → bool",
"description": "<p>Return if a time is between two other times (by default, inclusive for the start, exclusive for the end).</p>",
"example": "<p><strong>Example:</strong> Retrieve all the posts that were posted between December 1st, 2013 (inclusive) and December 10th, 2013 (exclusive).</p>\n<pre><code>r.table(\"posts\").filter(\n r.row('date').during(r.time(2013, 12, 1), r.time(2013, 12, 10))\n).run(conn, callback)\n</code></pre>",
"io": [
[
"time",
"bool"
]
],
"name": "during",
"url": "during"
},
"api/javascript/each/": {
"body": "cursor.each(callback[, onFinishedCallback])array.each(callback[, onFinishedCallback])feed.each(callback)",
"description": "<p>Lazily iterate over the result set one element at a time.</p>",
"example": "<p><strong>Example:</strong> Let's process all the elements!</p>\n<pre><code>cursor.each(function(err, row) {\n if (err) throw err;\n processRow(row);\n});\n</code></pre>",
"io": [
[
"cursor",
"undefined"
]
],
"name": "each",
"url": "each"
},
"api/javascript/each_async/": {
"body": "cursor.eachAsync(function) → promisearray.eachAsync(function) → promisefeed.eachAsync(function) → promise",
"description": "<p>Lazily iterate over a result set one element at a time in an identical fashion to <a href=\"/api/javascript/each/\">each</a>, returning a Promise that will be resolved once all rows are returned.</p>",
"example": "<p><strong>Example:</strong> Process all the elements in a stream.</p>\n<pre><code>cursor.eachAsync(function(row) {\n // if a Promise is returned, it will be processed before the cursor\n // continues iteration.\n return asyncRowHandler(row);\n}).then(function () {\n console.log(\"done processing\"); \n});\n</code></pre>",
"io": [
[
"cursor",
"undefined"
]
],
"name": "eachAsync",
"url": "each_async"
},
"api/javascript/epoch_time/": {
"body": "r.epochTime(epochTime) → time",
"description": "<p>Create a time object based on seconds since epoch. The first argument is a double and\nwill be rounded to three decimal places (millisecond-precision).</p>",
"example": "<p><strong>Example:</strong> Update the birthdate of the user \"John\" to November 3rd, 1986.</p>\n<pre><code>r.table(\"user\").get(\"John\").update({birthdate: r.epochTime(531360000)})\n .run(conn, callback)\n</code></pre>",
"io": [
[
"r",
"time"
]
],
"name": "epochTime",
"url": "epoch_time"
},
"api/javascript/eq/": {
"body": "value.eq(value[, value, ...]) → bool",
"description": "<p>Test if two or more values are equal.</p>",
"example": "<p><strong>Example:</strong> See if a user's <code>role</code> field is set to <code>administrator</code>. </p>\n<pre><code>r.table('users').get(1)('role').eq('administrator').run(conn, callback);\n</code></pre>",
"io": [
[
"value",
"bool"
]
],
"name": "eq",
"url": "eq"
},
"api/javascript/eq_join/": {
"body": "sequence.eqJoin(leftField, rightTable[, {index:'id'}]) → sequencesequence.eqJoin(predicate_function, rightTable[, {index:'id'}]) → sequence",
"description": "<p>Join tables using a field or function on the left-hand sequence matching primary keys or secondary indexes on the right-hand table. <code>eqJoin</code> is more efficient than other ReQL join types, and operates much faster. Documents in the result set consist of pairs of left-hand and right-hand documents, matched when the field on the left-hand side exists and is non-null and an entry with that field's value exists in the specified index on the right-hand side.</p>\n<p><strong>Example:</strong> Match players with the games they've played against one another.</p>\n<p><code>js\nr.table('players').eqJoin('gameId', r.table('games')).run(conn, callback)</code></p>",
"example": "",
"io": [
[
"sequence",
"stream"
],
[
"array",
"array"
]
],
"name": "eqJoin",
"url": "eq_join"
},
"api/javascript/error/": {
"body": "r.error(message) → error",
"description": "<p>Throw a runtime error. If called with no arguments inside the second argument to <code>default</code>, re-throw the current error.</p>",
"example": "<p><strong>Example:</strong> Iron Man can't possibly have lost a battle:</p>\n<pre><code>r.table('marvel').get('IronMan').do(function(ironman) {\n return r.branch(ironman('victories').lt(ironman('battles')),\n r.error('impossible code path'),\n ironman)\n}).run(conn, callback)\n</code></pre>",
"io": [
[
"r",
"error"
]
],
"name": "error",
"url": "error"
},
"api/javascript/event_emitter-cursor/": {
"body": "cursor.addListener(event, listener)cursor.on(event, listener)cursor.once(event, listener)cursor.removeListener(event, listener)cursor.removeAllListeners([event])cursor.setMaxListeners(n)cursor.listeners(event)cursor.emit(event, [arg1], [arg2], [...])",
"description": "<p>Cursors and feeds implement the same interface as Node's <a href=\"http://nodejs.org/api/events.html#events_class_events_eventemitter\">EventEmitter</a>.</p>",
"example": "",
"io": [
[
"cursor",
"undefined"
]
],
"name": "EventEmitter (cursor)",
"url": "event_emitter-cursor"
},
"api/javascript/event_emitter/": {
"body": "connection.addListener(event, listener)connection.on(event, listener)connection.once(event, listener)connection.removeListener(event, listener)connection.removeAllListeners([event])connection.setMaxListeners(n)connection.listeners(event)connection.emit(event, [arg1], [arg2], [...])",
"description": "<p>Connections implement the same interface as Node's <a href=\"http://nodejs.org/api/events.html#events_class_events_eventemitter\">EventEmitter</a>.\nThis allows you to listen for changes in connection state.</p>",
"example": "",
"name": "EventEmitter (connection)",
"url": "event_emitter"
},
"api/javascript/expr/": {
"body": "r.expr(value) → value",
"description": "<p>Construct a ReQL JSON object from a native object.</p>",
"example": "<p><strong>Example:</strong> Objects wrapped with <code>expr</code> can then be manipulated by ReQL API functions.</p>\n<pre><code>r.expr({a:'b'}).merge({b:[1,2,3]}).run(conn, callback)\n</code></pre>",
"io": [
[
"r",
"value"
]
],
"name": "expr",
"url": "expr"
},
"api/javascript/fill/": {
"body": "line.fill() → polygon",
"description": "<p>Convert a Line object into a Polygon object. If the last point does not specify the same coordinates as the first point, <code>polygon</code> will close the polygon by connecting them.</p>",
"example": "<p><strong>Example:</strong> Create a line object and then convert it to a polygon.</p>\n<pre><code>r.table('geo').insert({\n id: 201,\n rectangle: r.line(\n [-122.423246,37.779388],\n [-122.423246,37.329898],\n [-121.886420,37.329898],\n [-121.886420,37.779388]\n )\n}).run(conn, callback);\n\nr.table('geo').get(201).update({\n rectangle: r.row('rectangle').fill()\n}, {nonAtomic: true}).run(conn, callback);\n</code></pre>",
"io": [
[
"line",
"polygon"
]
],
"name": "fill",
"url": "fill"
},
"api/javascript/filter/": {
"body": "selection.filter(predicate_function[, {default: false}]) → selectionstream.filter(predicate_function[, {default: false}]) → streamarray.filter(predicate_function[, {default: false}]) → array",
"description": "<p>Get all the documents for which the given predicate is true.</p>\n<p><code>filter</code> can be called on a sequence, selection, or a field containing an array of\nelements. The return type is the same as the type on which the function was called on.</p>\n<p>The body of every filter is wrapped in an implicit <code>.default(false)</code>, which means that\nif a non-existence errors is thrown (when you try to access a field that does not exist\nin a document), RethinkDB will just ignore the document.\nThe <code>default</code> value can be changed by passing an object with a <code>default</code> field.\nSetting this optional argument to <code>r.error()</code> will cause any non-existence errors to\nreturn a <code>ReqlRuntimeError</code>.</p>",
"example": "<p><strong>Example:</strong> Get all the users that are 30 years old.</p>\n<pre><code>r.table('users').filter({age: 30}).run(conn, callback)\n</code></pre>",
"io": [
[
"sequence",
"selection"
],
[
"stream",
"stream"
],
[
"array",
"array"
]
],
"name": "filter",
"url": "filter"
},
"api/javascript/floor/": {
"body": "r.floor(number) → numbernumber.floor() → number",
"description": "<p>Rounds the given value down, returning the largest integer value less than or equal to the given value (the value's floor).</p>",
"example": "<p><strong>Example:</strong> Return the floor of 12.345.</p>\n<pre><code>> r.floor(12.345).run(conn, callback);\n\n12.0\n</code></pre>",
"io": [
[
"number",
"number"
]
],
"name": "floor",
"url": "floor"
},
"api/javascript/for_each/": {
"body": "sequence.forEach(write_function) → object",
"description": "<p>Loop over a sequence, evaluating the given write query for each element.</p>",
"example": "<p><strong>Example:</strong> Now that our heroes have defeated their villains, we can safely remove them from the villain table.</p>\n<pre><code>r.table('marvel').forEach(function(hero) {\n return r.table('villains').get(hero('villainDefeated')).delete()\n}).run(conn, callback)\n</code></pre>",
"io": [
[
"sequence",
"object"
]
],
"name": "forEach",
"url": "for_each"
},
"api/javascript/ge/": {
"body": "value.ge(value[, value, ...]) → bool",
"description": "<p>Compare values, testing if the left-hand value is greater than or equal to the right-hand.</p>",
"example": "<p><strong>Example:</strong> Test if a player has scored 10 points or more.</p>\n<pre><code>r.table('players').get(1)('score').ge(10).run(conn, callback);\n</code></pre>",
"io": [
[
"value",
"bool"
]
],
"name": "ge",
"url": "ge"
},
"api/javascript/geojson/": {
"body": "r.geojson(geojson) → geometry",
"description": "<p>Convert a <a href=\"http://geojson.org\">GeoJSON</a> object to a ReQL geometry object.</p>",
"example": "<p><strong>Example:</strong> Convert a GeoJSON object to a ReQL geometry object.</p>\n<pre><code>var geoJson = {\n 'type': 'Point',\n 'coordinates': [ -122.423246, 37.779388 ]\n};\nr.table('geo').insert({\n id: 'sfo',\n name: 'San Francisco',\n location: r.geojson(geoJson)\n}).run(conn, callback);\n</code></pre>",
"io": [
[
"r",
"geometry"
]
],
"name": "geojson",
"url": "geojson"
},
"api/javascript/get/": {
"body": "table.get(key) → singleRowSelection",
"description": "<p>Get a document by primary key.</p>\n<p>If no document exists with that primary key, <code>get</code> will return <code>null</code>.</p>",
"example": "<p><strong>Example:</strong> Find a document by UUID.</p>\n<pre><code>r.table('posts').get('a9849eef-7176-4411-935b-79a6e3c56a74').run(conn, callback)\n</code></pre>",
"io": [
[
"table",
"singleSelection"
]
],
"name": "get",
"url": "get"
},
"api/javascript/get_all/": {
"body": "table.getAll(key[, key2...], [, {index:'id'}]) → selection",
"description": "<p>Get all documents where the given value matches the value of the requested index.</p>",
"example": "<p><strong>Example:</strong> Secondary index keys are not guaranteed to be unique so we cannot query via <a href=\"/api/javascript/get/\">get</a> when using a secondary index.</p>\n<pre><code>r.table('marvel').getAll('man_of_steel', {index:'code_name'}).run(conn, callback)\n</code></pre>",
"io": [
[
"table",
"selection"
]
],
"name": "getAll",
"url": "get_all"
},
"api/javascript/get_field/": {
"body": "sequence.getField(attr) → sequencesingleSelection.getField(attr) → valueobject.getField(attr) → value",
"description": "<p>Get a single field from an object. If called on a sequence, gets that field from every\nobject in the sequence, skipping objects that lack it.</p>",
"example": "<p><strong>Example:</strong> What was Iron Man's first appearance in a comic?</p>\n<pre><code>r.table('marvel').get('IronMan').getField('firstAppearance').run(conn, callback)\n</code></pre>",
"io": [
[
"sequence",
"sequence"
],
[
"singleSelection",
"value"
],
[
"object",
"value"
]
],
"name": "getField",
"url": "get_field"
},
"api/javascript/get_intersecting/": {
"body": "table.getIntersecting(geometry, {index: 'indexname'}) → selection<stream>",
"description": "<p>Get all documents where the given geometry object intersects the geometry object of the requested geospatial index.</p>",
"example": "<p><strong>Example:</strong> Which of the locations in a list of parks intersect <code>circle1</code>?</p>\n<pre><code>var circle1 = r.circle([-117.220406,32.719464], 10, {unit: 'mi'});\nr.table('parks').getIntersecting(circle1, {index: 'area'}).run(conn, callback);\n</code></pre>",
"io": [
[
"table",
"stream"
]
],
"name": "getIntersecting",
"url": "get_intersecting"
},
"api/javascript/get_nearest/": {
"body": "table.getNearest(point, {index: 'indexname'[, maxResults: 100, maxDist: 100000, unit: 'm', geoSystem: 'WGS84']}) → selection<array>",
"description": "<p>Get all documents where the specified geospatial index is within a certain distance of the specified point (default 100 kilometers).</p>",
"example": "<p><strong>Example:</strong> Return a list of enemy hideouts within 5000 meters of the secret base.</p>\n<pre><code>var secretBase = r.point(-122.422876,37.777128);\nr.table('hideouts').getNearest(secretBase,\n {index: 'location', maxDist: 5000}\n).run(conn, callback)\n</code></pre>",
"io": [
[
"table",
"array"
]
],
"name": "getNearest",
"url": "get_nearest"
},
"api/javascript/group/": {
"body": "sequence.group(field | function..., [{index: <indexname>, multi: false}]) → grouped_stream",
"description": "<p>Takes a stream and partitions it into multiple groups based on the\nfields or functions provided. Commands chained after <code>group</code> will be\ncalled on each of these grouped sub-streams, producing grouped data.</p>",
"example": "<p><strong>Example:</strong> What is each player's best game?</p>\n<pre><code>r.table('games').group('player').max('points').run(conn, callback)\n</code></pre>",
"io": [
[
"sequence",
"grouped_stream"
]
],
"name": "group",
"url": "group"
},
"api/javascript/gt/": {
"body": "value.gt(value[, value, ...]) → bool",
"description": "<p>Compare values, testing if the left-hand value is greater than the right-hand.</p>",
"example": "<p><strong>Example:</strong> Test if a player has scored more than 10 points.</p>\n<pre><code>r.table('players').get(1)('score').gt(10).run(conn, callback);\n</code></pre>",
"io": [
[
"value",
"bool"
]
],
"name": "gt",
"url": "gt"
},
"api/javascript/has_fields/": {
"body": "sequence.hasFields([selector1, selector2...]) → streamarray.hasFields([selector1, selector2...]) → arrayobject.hasFields([selector1, selector2...]) → boolean",
"description": "<p>Test if an object has one or more fields. An object has a field if it has that key and the key has a non-null value. For instance, the object <code>{'a': 1,'b': 2,'c': null}</code> has the fields <code>a</code> and <code>b</code>.</p>",
"example": "<p><strong>Example:</strong> Return the players who have won games.</p>\n<pre><code>r.table('players').hasFields('games_won').run(conn, callback)\n</code></pre>",
"io": [
[
"sequence",
"stream"
],
[
"array",
"array"
],
[
"singleSelection",
"boolean"
],
[
"object",
"boolean"
]
],
"name": "hasFields",
"url": "has_fields"
},
"api/javascript/hours/": {
"body": "time.hours() → number",
"description": "<p>Return the hour in a time object as a number between 0 and 23.</p>",
"example": "<p><strong>Example:</strong> Return all the posts submitted after midnight and before 4am.</p>\n<pre><code>r.table(\"posts\").filter(function(post) {\n return post(\"date\").hours().lt(4)\n})\n</code></pre>",
"io": [
[
"time",
"number"
]
],
"name": "hours",
"url": "hours"
},
"api/javascript/http/": {
"body": "r.http(url [, options]) → value",
"description": "<p>Retrieve data from the specified URL over HTTP. The return type depends on the <code>resultFormat</code> option, which checks the <code>Content-Type</code> of the response by default.</p>",
"example": "<p><strong>Example:</strong> Perform a simple HTTP <code>GET</code> request, and store the result in a table.</p>\n<pre><code>r.table('posts').insert(r.http('http://httpbin.org/get')).run(conn, callback)\n</code></pre>",
"io": [
[
"r",
"value"
],
[
"r",
"stream"
]
],
"name": "http",
"url": "http"
},
"api/javascript/in_timezone/": {
"body": "time.inTimezone(timezone) → time",
"description": "<p>Return a new time object with a different timezone. While the time stays the same, the results returned by methods such as hours() will change since they take the timezone into account. The timezone argument has to be of the ISO 8601 format.</p>",
"example": "<p><strong>Example:</strong> Hour of the day in San Francisco (UTC/GMT -8, without daylight saving time).</p>\n<pre><code>r.now().inTimezone('-08:00').hours().run(conn, callback)\n</code></pre>",
"io": [
[
"time",
"time"
]
],
"name": "inTimezone",
"url": "in_timezone"
},
"api/javascript/includes/": {
"body": "sequence.includes(geometry) → sequencegeometry.includes(geometry) → bool",
"description": "<p>Tests whether a geometry object is completely contained within another. When applied to a sequence of geometry objects, <code>includes</code> acts as a <a href=\"/api/javascript/filter\">filter</a>, returning a sequence of objects from the sequence that include the argument.</p>",
"example": "<p><strong>Example:</strong> Is <code>point2</code> included within a 2000-meter circle around <code>point1</code>?</p>\n<pre><code>var point1 = r.point(-117.220406,32.719464);\nvar point2 = r.point(-117.206201,32.725186);\nr.circle(point1, 2000).includes(point2).run(conn, callback);\n// result returned to callback \ntrue\n</code></pre>",
"io": [
[
"geometry",
"bool"
],
[
"sequence",
"sequence"
]
],
"name": "includes",
"url": "includes"
},
"api/javascript/index_create/": {
"body": "table.indexCreate(indexName[, indexFunction][, {multi: false, geo: false}]) → object",
"description": "<p>Create a new secondary index on a table.</p>",
"example": "<p><strong>Example:</strong> Create a simple index based on the field <code>postId</code>.</p>\n<pre><code>r.table('comments').indexCreate('postId').run(conn, callback)\n</code></pre>",
"io": [
[
"table",
"object"
]
],
"name": "indexCreate",
"url": "index_create"
},
"api/javascript/index_drop/": {
"body": "table.indexDrop(indexName) → object",
"description": "<p>Delete a previously created secondary index of this table.</p>",
"example": "<p><strong>Example:</strong> Drop a secondary index named 'code_name'.</p>\n<pre><code>r.table('dc').indexDrop('code_name').run(conn, callback)\n</code></pre>",
"io": [
[
"table",
"object"
]
],
"name": "indexDrop",
"url": "index_drop"
},
"api/javascript/index_list/": {
"body": "table.indexList() → array",
"description": "<p>List all the secondary indexes of this table.</p>",