UNPKG

27.9 kBMarkdownView Raw
1# fauna-shell
2
3<!-- [![Version](https://img.shields.io/npm/v/fauna.svg)](https://npmjs.org/package/fauna)
4[![CircleCI](https://circleci.com/gh/fauna/fauna/tree/master.svg?style=shield)](https://circleci.com/gh/fauna/fauna/tree/master)
5[![Appveyor CI](https://ci.appveyor.com/api/projects/status/github/fauna/fauna?branch=master&svg=true)](https://ci.appveyor.com/project/fauna/fauna/branch/master)
6[![Codecov](https://codecov.io/gh/fauna/fauna/branch/master/graph/badge.svg)](https://codecov.io/gh/fauna/fauna)
7[![Downloads/week](https://img.shields.io/npm/dw/fauna.svg)](https://npmjs.org/package/fauna)
8[![License](https://img.shields.io/npm/l/fauna.svg)](https://github.com/fauna/fauna/blob/master/package.json) -->
9
10This tools gives you access to [Fauna](http://fauna.com/) directly from your CLI.
11
12It also includes a [Shell](#shell) so you can issue queries to Fauna without needing to install additional libraries.
13
14You can install it via npm like this:
15
16```sh-session
17$ npm install -g fauna-shell
18```
19
20<!-- toc -->
21
22- [Usage](#usage)
23- [Technical Requirements](#technical-requirements)
24- [Configuration](#configuration)
25- [Shell](#shell)
26- [Command Details](#command-details)
27- [Connecting to different endpoints](#connecting-to-different-endpoints)
28- [Overriding Connection Parameters](#overriding-connection-parameters)
29- [Executing queries from a file](#executing-queries-from-a-file)
30- [List of Commands](#list-of-commands)
31 <!-- tocstop -->
32
33# Usage
34
35The **fauna-shell** allows you to do things like _creating_, _deleting_ and _listings_ databases.
36
37First lets configure our connection to a Fauna account. (If you don't have an account, you can create a free one [here](https://dashboard.fauna.com)).
38
39Let's run the following command:
40
41```sh-session
42$ fauna cloud-login
43```
44
45You will be prompted for your `email` and `password` from your [Fauna](https://dashboard.fauna.com) account.
46
47If you would like to use 3rd party identity providers like Github or Netlify, please refer to [this guide](https://docs.fauna.com/fauna/current/start/cloud-github.html).
48
49Now that we have an endpoint to connect to we can try to create a database to start interacting with Fauna. See [connecting to different endpoints](#connecting-to-different-endpoints).
50
51This is how you can create a database called `my_app`:
52
53```sh-session
54$ fauna create-database my_app
55creating database my_app
56
57created database my_app
58
59To start a shell with your new database, run:
60
61 fauna shell my_app
62
63Or, to create an application key for your database, run:
64
65 fauna create-key my_app
66```
67
68And then listing your databases:
69
70```sh-session
71$ fauna list-databases
72listing databases
73my_app
74my_second_app
75my_other_app
76```
77
78You can also delete a particular database:
79
80```sh-session
81$ fauna delete-database my_other_app
82deleting database 'my_other_app'
83database 'my_other_app' deleted
84```
85
86You can also `create`, `list`, and `delete` _keys_.
87
88This is how you create a key for the database `my_app`:
89
90```sh-session
91$ fauna create-key my_app
92creating key for database 'my_app' with role 'admin'
93
94created key for database 'my_app' with role 'admin'.
95secret: ****************************************
96
97To access 'my_app' with this key, create a client using
98the driver library for your language of choice using
99the above secret.
100```
101
102This is how to list keys (the results may differ from what you see in your database)
103
104```sh-session
105$ fauna list-keys
106listing keys
107Key ID Database Role
108203269476002562560 my_app admin
109203269731203940864 my_app admin
110203269732275585536 my_app admin
111203269735610057216 test admin
112```
113
114And then delete the key with id: `200219702370238976`:
115
116```sh-session
117$ fauna delete-key 200219702370238976
118deleting key 200219702370238976
119key 200219702370238976 deleted
120```
121
122See [Commands](#commands) for a list of commands and help on their usage.
123
124# Technical Requirements
125
126In order to use Fauna Shell, you will need to meet these system requirements:
127
128**Node.js version**
129
130- `>= v10.0.0`
131- `< v12.17.0`
132
133# Configuration
134
135By default, requests made when using the `cloud-login` command will hit `https://auth-console.fauna-preview.com/login`. You can change this behavior by defining the `FAUNA_SHELL_LOGIN_URL` environment variable in your `.env`
136
137For example:
138
139```bash
140FAUNA_SHELL_LOGIN_URL=https://www.mycustomdomain.com/login
141```
142
143# Shell
144
145The Fauna Shell lets you issue queries directly to your Fauna database without the need for installing additional libraries.
146
147Let's create a database and then we'll jump straight into the Shell to start playing with Fauna's data model.
148
149```sh-session
150$ fauna create-database my_app
151```
152
153Our next step is to start the shell for a specific database, in this case `my_app`:
154
155```sh-session
156$ fauna shell my_app
157Starting shell for database my_app
158Connected to http://127.0.0.1:8443
159Type Ctrl+D or .exit to exit the shell
160my_app>
161```
162
163Once you have the prompt ready, you can start issues queries against your Fauna database. (Note that the results shown here might vary from the ones you see while running the examples).
164
165```javascript
166my_app> Collection.create({ name: "Post" })
167{
168 name: "Post",
169 coll: Collection,
170 ts: Time("2023-08-15T16:06:01.120Z"),
171 indexes: {},
172 constraints: []
173}
174```
175
176Let's create an index for our collection `Post`.
177
178```javascript
179
180my_app> Post.definition.update({ indexes: { byTitle: { terms: [{ field: ".title" }] } } })
181{
182 name: "Post",
183 coll: Collection,
184 ts: Time("2023-08-15T16:07:10.800Z"),
185 indexes: {
186 byTitle: {
187 terms: [
188 {
189 field: ".title"
190 }
191 ],
192 queryable: true,
193 status: "complete"
194 }
195 },
196 constraints: []
197}
198```
199
200Let's insert a new `Post` document:
201
202```javascript
203my_app> Post.create({ title: "What I had for breakfast .." })
204{
205 id: "373143369066480128",
206 coll: Post,
207 ts: Time("2023-08-15T16:14:57.440Z"),
208 title: "What I had for breakfast .."
209}
210```
211
212We can also insert items in bulk by using iterator functions on arrays.
213
214```javascript
215my_app> ["My cat and other marvels", "Pondering during a commute", "Deep meanings in a latte"].map(title => Post.create({ title: title }))
216[
217 {
218 id: "373143473418666496",
219 coll: Post,
220 ts: Time("2023-08-15T16:16:36.960Z"),
221 title: "My cat and other marvels"
222 },
223 {
224 id: "373143473419715072",
225 coll: Post,
226 ts: Time("2023-08-15T16:16:36.960Z"),
227 title: "Pondering during a commute"
228 },
229 {
230 id: "373143473420763648",
231 coll: Post,
232 ts: Time("2023-08-15T16:16:36.960Z"),
233 title: "Deep meanings in a latte"
234 }
235]
236```
237
238Now let's try to fetch our post about _latte_. We need to access it by _id_ like this:
239
240```javascript
241my_app> Post.byId("373143473420763648")
242{
243 id: "373143473420763648",
244 coll: Post,
245 ts: Time("2023-08-15T16:16:36.960Z"),
246 title: "Deep meanings in a latte"
247}
248```
249
250Now let's update our post about our cat, by adding some tags:
251
252```javascript
253my_app> Post.byId("373143473420763648")!.update({ tags: ["cute", "pet"] })
254{
255 id: "373143473420763648",
256 coll: Post,
257 ts: Time("2023-08-15T16:17:41Z"),
258 title: "Deep meanings in a latte",
259 tags: [
260 "cute",
261 "pet"
262 ]
263}
264```
265
266And now let's try to change the content of that post:
267
268```javascript
269my_app> Post.byId("373143473418666496")!.replace({ title: "My dog and other marvels" })
270{
271 id: "373143473418666496",
272 coll: Post,
273 ts: Time("2023-08-15T16:18:32.680Z"),
274 title: "My dog and other marvels"
275}
276```
277
278Now let's try to delete our post about _latte_:
279
280```javascript
281my_app> Post.byId("373143473420763648")!.delete()
282Post.byId("373143473420763648") /* not found */
283```
284
285If we try to fetch it, we will receive a null document:
286
287```javascript
288my_app> Post.byId("373143473420763648")
289Post.byId("373143473420763648") /* not found */
290```
291
292Finally you can exit the _shell_ by pressing `ctrl+d`.
293
294# Command Details
295
296<!-- details -->
297
298```sh-session
299$ fauna COMMAND
300running command...
301$ fauna (-v|--version|version)
302fauna/0.0.1 darwin-x64 node-v8.11.1
303$ fauna --help [COMMAND]
304USAGE
305 $ fauna COMMAND
306...
307```
308
309# Connecting to different endpoints
310
311We can add endpoints by calling the following command `add-endpoint`. We will be prompted to enter the authentication key and an alias for the endpoint.
312
313```sh-session
314$ fauna add-endpoint "https://example.com"
315Endpoint Key: ****************************************
316Endpoint Alias [example.com]: example_alias
317```
318
319The _Endpoint Alias_ should be a name that helps you remember the purpose of this endpoint.
320
321If we have defined many endpoints, we could set one of them as the default one with the `default-endpoint` command:
322
323```sh-session
324$ fauna default-endpoint cloud
325```
326
327The _default endpoint_ will be used by the shell to connect to Fauna if the `--endpoint` flag is not set.
328
329Endpoints can be listed with the `list-endpoints` command like this:
330
331```sh-session
332$ fauna list-endpoints
333localhost
334cloud *
335cluster-us-east
336```
337
338There we see that the `cloud` endpoint has a `*` next to its name, meaning that it's the current default one.
339
340Finally, endpoints will be saved to a `~/.fauna-shell` file like this:
341
342```ini
343default=cloud
344
345[localhost]
346domain=127.0.0.1
347port=8443
348scheme=http
349secret=secret
350graphqlHost=127.0.0.1
351graphqlPort=8084
352
353
354[cloud]
355domain=db.fauna.com
356scheme=https
357secret=FAUNA_SECRET_KEY
358graphqlHost=graphql.fauna.com
359graphqlPort=443
360
361[cluster-us-east]
362domain=cluster-us-east.example.com
363port=443
364scheme=https
365secret=OTHER_FAUNA_SECRET
366graphqlHost=cluster-us-east.example.com
367graphqlPort=443
368```
369
370# Connecting to local endpoints
371
372If you are running Fauna locally using our Docker images, you may need to configure the Shell to work with local endpoints so you can interact with the databases running in the Docker containers.
373
374Once you've installed the Shell and logged in, you can configure this by doing the following:
375
3761. Run `fauna list-endpoints` to see all your endpoints. If you haven't added any yet, you should just see the `cloud` endpoint that was added when you went through the login flow.
377
3782. By default, the Fauna Docker image serves data via port 8443 (check your Docker logs to confirm the port number). To add this, run the following:
379
380```bash
381fauna add-endpoint http://localhost:8443 # Doesn't work with HTTPS
382```
383
3843. When prompted, provide the endpoint key and then give it a name (ex. `localhost`)
385
3864. Now, you can interact with your local database through the Fauna Shell by running the command below:
387
388```bash
389fauna shell --endpoint localhost
390```
391
392# Overriding Connection Parameters
393
394Most commands support the following options. You can specify them if you want to connect to a local instance of Fauna.
395
396```
397OPTIONS
398 --domain=domain [default: db.fauna.com] Fauna server domain
399 --port=port [default: 443] Connection port
400 --scheme=https|http [default: https] Connection scheme
401 --secret=secret Fauna secret key
402 --timeout=timeout [default: 80] Connection timeout in milliseconds
403 --endpoint=alias Overrides the default endpoint set in ~/.fauna-shell
404 --graphqlHost=domain [default: graphql.fauna.com] The Fauna GraphQL API host
405 --graphqlPort=port [default: 443] The Fauna GraphQL API port to connect to
406```
407
408They can be used like this:
409
410```sh-session
411$ fauna create-database testdb --domain=127.0.0.1 port=8443 --scheme=http --secret=YOUR_FAUNA_SECRET_KEY --timeout=42 --graphqlHost=127.0.0.1 --graphqlPort=443
412```
413
414Options provided via the CLI will override the values set in the `.fauna-shell` config file.
415
416For example you can start a shell to a different endpoint from the one set in `.fauna-shell`:
417
418```sh-session
419$ fauna shell my_app --endpoint=endpoint_alias
420```
421
422Any options that are not specified either via the `.fauna-shell` config file or the CLI will be set to the defaults offered by the [faunadb-js client](https://github.com/fauna/faunadb-js).
423
424# Executing queries from a file
425
426You can also tell the shell to execute a list of queries that you have stored in a file. For example, you can have a file that creates a collection called `setup.fql`:
427
428```javascript
429Collection.create({
430 name: "Post",
431 indexes: {
432 byTitle: {
433 terms: [{ field: ".title" }]
434 }
435 }
436})
437```
438
439Once the collection is created, you can execute queries against it in another `.fql` file:
440
441```
442Post.create({
443 title: "What I had for breakfast .."
444})
445
446[
447 "My cat and other marvels",
448 "Pondering during a commute",
449 "Deep meanings in a latte",
450].map(title => {
451 Post.create({
452 title: title
453 })
454})
455```
456
457You can tell Fauna Shell to execute all those queries for you by running the following command:
458
459```bash
460$ fauna eval my_app --file=./setup.fql
461$ fauna eval my_app --file=./queries.fql
462```
463
464Where `my_app` is the name of your database, and `./queries.fql` is the path to the file where you saved the queries. If `my_app` is left out it will execute the queries file on the default fauna shell endpoint.
465
466<!-- detailsstop -->
467
468# List of Commands
469
470<!-- commands -->
471
472- [fauna-shell](#fauna-shell)
473- [Usage](#usage)
474- [Technical Requirements](#technical-requirements)
475- [Configuration](#configuration)
476- [Shell](#shell)
477- [Command Details](#command-details)
478- [Connecting to different endpoints](#connecting-to-different-endpoints)
479- [Connecting to local endpoints](#connecting-to-local-endpoints)
480- [Overriding Connection Parameters](#overriding-connection-parameters)
481- [Executing queries from a file](#executing-queries-from-a-file)
482- [List of Commands](#list-of-commands)
483 - [`fauna add-endpoint ENDPOINT`](#fauna-add-endpoint-endpoint)
484 - [`fauna autocomplete [SHELL]`](#fauna-autocomplete-shell)
485 - [`fauna cloud-login`](#fauna-cloud-login)
486 - [`fauna create-database DBNAME`](#fauna-create-database-dbname)
487 - [`fauna create-key DBNAME [ROLE]`](#fauna-create-key-dbname-role)
488 - [`fauna default-endpoint ENDPOINT_ALIAS`](#fauna-default-endpoint-endpoint_alias)
489 - [`fauna delete-database DBNAME`](#fauna-delete-database-dbname)
490 - [`fauna delete-endpoint ENDPOINT_ALIAS`](#fauna-delete-endpoint-endpoint_alias)
491 - [`fauna delete-key KEYNAME`](#fauna-delete-key-keyname)
492 - [`fauna help [COMMAND]`](#fauna-help-command)
493 - [`fauna list-databases`](#fauna-list-databases)
494 - [`fauna list-endpoints`](#fauna-list-endpoints)
495 - [`fauna list-keys`](#fauna-list-keys)
496 - [`fauna run-queries DBNAME`](#fauna-run-queries-dbname)
497 - [`fauna shell [DBNAME]`](#fauna-shell-dbname)
498 - [`fauna import`](#fauna-import)
499 - [`fauna eval [DBNAME] [QUERY]`](#fauna-eval-dbname-query)
500 - [`fauna upload-graphql-schema graphqlFilePath`](#fauna-upload-graphql-schema-graphqlfilepath)
501 - [`fauna import --path FILE_PATH`](#fauna-import---path-file_path)
502- [Development](#development)
503
504## `fauna add-endpoint ENDPOINT`
505
506Adds a connection endpoint for Fauna.
507
508```
509USAGE
510 $ fauna add-endpoint ENDPOINT
511
512ARGUMENTS
513 ENDPOINT Fauna server endpoint
514
515DESCRIPTION
516 Adds a connection endpoint for Fauna.
517
518EXAMPLE
519 $ fauna add-endpoint https://db.fauna.com:443
520 $ fauna add-endpoint http://localhost:8443/ --alias localhost --key secret
521```
522
523_See code: [src/commands/add-endpoint.js](src/commands/add-endpoint.js)_
524
525## `fauna autocomplete [SHELL]`
526
527display autocomplete installation instructions
528
529```
530USAGE
531 $ fauna autocomplete [SHELL]
532
533ARGUMENTS
534 SHELL shell type
535
536OPTIONS
537 -r, --refresh-cache Refresh cache (ignores displaying instructions)
538
539EXAMPLES
540 $ fauna autocomplete
541 $ fauna autocomplete bash
542 $ fauna autocomplete zsh
543 $ fauna autocomplete --refresh-cache
544```
545
546_See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v0.1.0/src/commands/autocomplete/index.ts)_
547
548## `fauna cloud-login`
549
550Adds a Fauna endpoint.
551
552```
553USAGE
554 $ fauna cloud-login
555
556DESCRIPTION
557 Adds a Fauna endpoint.
558
559EXAMPLE
560 $ fauna cloud-login
561```
562
563_See code: [src/commands/cloud-login.js](commands/cloud-login.js)_
564
565## `fauna create-database DBNAME`
566
567Creates a database
568
569```
570USAGE
571 $ fauna create-database DBNAME
572
573ARGUMENTS
574 DBNAME database name
575
576OPTIONS
577 --domain=domain Fauna server domain
578 --endpoint=endpoint Fauna server endpoint
579 --port=port Connection port
580 --scheme=https|http Connection scheme
581 --secret=secret Fauna secret key
582 --timeout=timeout Connection timeout in milliseconds
583
584DESCRIPTION
585 Creates a database
586
587EXAMPLE
588 $ fauna create-database dbname
589```
590
591_See code: [src/commands/create-database.js](commands/create-database.js)_
592
593## `fauna create-key DBNAME [ROLE]`
594
595Creates a key for the specified database
596
597```
598USAGE
599 $ fauna create-key DBNAME [ROLE]
600
601ARGUMENTS
602 DBNAME database name
603 ROLE (admin|server|server-readonly|client) key user role
604
605OPTIONS
606 --domain=domain Fauna server domain
607 --endpoint=endpoint Fauna server endpoint
608 --port=port Connection port
609 --scheme=https|http Connection scheme
610 --secret=secret Fauna secret key
611 --timeout=timeout Connection timeout in milliseconds
612
613DESCRIPTION
614 Creates a key for the specified database
615
616EXAMPLE
617 $ fauna create-key dbname admin
618```
619
620_See code: [src/commands/create-key.js](src/commands/create-key.js)_
621
622## `fauna default-endpoint ENDPOINT_ALIAS`
623
624Sets an endpoint as the default one
625
626```
627USAGE
628 $ fauna default-endpoint ENDPOINT_ALIAS
629
630ARGUMENTS
631 ENDPOINT_ALIAS Fauna server endpoint alias
632
633DESCRIPTION
634 Sets an endpoint as the default one
635
636EXAMPLE
637 $ fauna default-endpoint endpoint
638```
639
640_See code: [src/commands/default-endpoint.js](src/commands/default-endpoint.js)_
641
642## `fauna delete-database DBNAME`
643
644Deletes a database
645
646```
647USAGE
648 $ fauna delete-database DBNAME
649
650ARGUMENTS
651 DBNAME database name
652
653OPTIONS
654 --domain=domain Fauna server domain
655 --endpoint=endpoint Fauna server endpoint
656 --port=port Connection port
657 --scheme=https|http Connection scheme
658 --secret=secret Fauna secret key
659 --timeout=timeout Connection timeout in milliseconds
660
661DESCRIPTION
662 Deletes a database
663
664EXAMPLE
665 $ fauna delete-database dbname
666```
667
668_See code: [src/commands/delete-database.js](src/commands/delete-database.js)_
669
670## `fauna delete-endpoint ENDPOINT_ALIAS`
671
672Deletes a connection endpoint.
673
674```
675USAGE
676 $ fauna delete-endpoint ENDPOINT_ALIAS
677
678ARGUMENTS
679 ENDPOINT_ALIAS Fauna server endpoint alias
680
681DESCRIPTION
682 Deletes a connection endpoint.
683
684EXAMPLE
685 $ fauna delete-endpoint endpoint_alias
686```
687
688_See code: [src/commands/delete-endpoint.js](src/commands/delete-endpoint.js)_
689
690## `fauna delete-key KEYNAME`
691
692Deletes a key
693
694```
695USAGE
696 $ fauna delete-key KEYNAME
697
698ARGUMENTS
699 KEYNAME key name
700
701OPTIONS
702 --domain=domain Fauna server domain
703 --endpoint=endpoint Fauna server endpoint
704 --port=port Connection port
705 --scheme=https|http Connection scheme
706 --secret=secret Fauna secret key
707 --timeout=timeout Connection timeout in milliseconds
708
709DESCRIPTION
710 Deletes a key
711
712EXAMPLE
713 $ fauna delete-key 123456789012345678
714```
715
716_See code: [src/commands/delete-key.js](src/commands/delete-key.js)_
717
718## `fauna help [COMMAND]`
719
720display help for fauna
721
722```
723USAGE
724 $ fauna help [COMMAND]
725
726ARGUMENTS
727 COMMAND command to show help for
728
729OPTIONS
730 --all see all commands in CLI
731```
732
733_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v1.2.11/src/commands/help.ts)_
734
735## `fauna list-databases`
736
737Lists child databases in the current database
738
739```
740USAGE
741 $ fauna list-databases
742
743OPTIONS
744 --domain=domain Fauna server domain
745 --endpoint=endpoint Fauna server endpoint
746 --port=port Connection port
747 --scheme=https|http Connection scheme
748 --secret=secret Fauna secret key
749 --timeout=timeout Connection timeout in milliseconds
750
751DESCRIPTION
752 Lists child databases in the current database
753
754EXAMPLE
755 $ fauna list-databases
756```
757
758_See code: [src/commands/list-databases.js](src/commands/list-databases.js)_
759
760## `fauna list-endpoints`
761
762Lists connection endpoints.
763
764```
765USAGE
766 $ fauna list-endpoints
767
768DESCRIPTION
769 Lists connection endpoints.
770
771EXAMPLE
772 $ fauna list-endpoints
773```
774
775_See code: [src/commands/list-endpoints.js](src/commands/list-endpoints.js)_
776
777## `fauna list-keys`
778
779List keys in the current database or in its child databases
780
781```
782USAGE
783 $ fauna list-keys
784
785OPTIONS
786 --domain=domain Fauna server domain
787 --endpoint=endpoint Fauna server endpoint
788 --port=port Connection port
789 --scheme=https|http Connection scheme
790 --secret=secret Fauna secret key
791 --timeout=timeout Connection timeout in milliseconds
792
793DESCRIPTION
794 List keys in the current database or in its child databases
795
796EXAMPLE
797 $ fauna list-keys
798```
799
800_See code: [src/commands/list-keys.js](src/commands/list-keys.js)_
801
802## `fauna run-queries DBNAME`
803
804Runs the queries found on the file passed to the command.
805
806```
807USAGE
808 $ fauna run-queries DBNAME
809
810ARGUMENTS
811 DBNAME database name
812
813OPTIONS
814 --domain=domain Fauna server domain
815 --endpoint=endpoint Fauna server endpoint
816 --file=file File where to read queries from
817 --port=port Connection port
818 --scheme=https|http Connection scheme
819 --secret=secret Fauna secret key
820 --timeout=timeout Connection timeout in milliseconds
821
822DESCRIPTION
823 Runs the queries found on the file passed to the command.
824
825EXAMPLE
826 $ fauna run-queries dbname --file=/path/to/queries.fql
827```
828
829_See code: [src/commands/run-queries.js](src/commands/run-queries.js)_
830
831## `fauna shell [DBNAME]`
832
833Starts an interactive shell.
834
835```
836USAGE
837 $ fauna shell [DBNAME]
838
839ARGUMENTS
840 DBNAME database name
841
842OPTIONS
843 --domain=domain Fauna server domain
844 --endpoint=endpoint Fauna server endpoint
845 --port=port Connection port
846 --scheme=https|http Connection scheme
847 --secret=secret Fauna secret key
848 --timeout=timeout Connection timeout in milliseconds
849 --version=4|10 [default: 10] FQL version to use
850
851DESCRIPTION
852 Starts an interactive shell.
853
854EXAMPLE
855 $ fauna shell dbname
856```
857
858_See code: [src/commands/shell.js](src/commands/shell.js)_
859
860## `fauna eval [DBNAME] [QUERY]`
861
862Evaluates a fauna query
863
864```
865USAGE
866 $ fauna eval [DBNAME] [QUERY]
867
868ARGUMENTS
869 QUERY FQL query to execute
870 DBNAME Database name
871
872OPTIONS
873 --domain=domain Fauna server domain
874 --endpoint=endpoint Fauna server endpoint
875 --file=file File where to read queries from
876 --format=json|shell|json-tagged [default: shell if tty, json if no tty] Output format
877 --output=output File to write output to
878 --port=port Connection port
879 --scheme=https|http Connection scheme
880 --secret=secret Fauna secret key
881 --stdin Read file input from stdin. Writes to stdout by default
882 --timeout=timeout Connection timeout in milliseconds
883 --version=4|10 [default: 10] FQL version to use
884
885DESCRIPTION
886 Runs the specified query. Can read from stdin, file or command line.
887 Outputs to either stdout or file.
888 Output format can be specified.
889
890EXAMPLES
891 $ fauna eval "Collection.all()"
892 $ fauna eval nestedDbName "Collection.all()"
893 $ fauna eval --file=/path/to/queries.fql
894 $ echo "1 + 1" | fauna eval
895 $ fauna eval "2 + 3" --output=/tmp/result"
896 $ fauna eval "2 + 3" --format=json --output=/tmp/result"
897```
898
899_See code: [src/commands/eval.js](src/commands/eval.js)_
900
901## `fauna import`
902
903Import data to Fauna
904
905```
906USAGE
907 $ fauna import --path [DATA]
908
909OPTIONS
910 --allow-short-rows Allows rows which are shorter than the number of headers
911 --append Allows appending documents to a non-empty collection
912 --collection=collection Collection name. When not specified, the collection name is the filename when --path is file
913 --db=db Child database name; imported documents are stored in this database
914 --domain=domain Fauna server domain
915 --endpoint=endpoint Fauna server endpoint
916 --path=path (required) Path to .csv/.json file, or path to folder containing .csv/.json files
917 --port=port Connection port
918 --scheme=https|http Connection scheme
919 --secret=secret Fauna secret key
920 --timeout=timeout Connection timeout in milliseconds
921
922 --type=type Column type casting, converts the column value to a Fauna type.
923 Format: <column>::<type>
924 <column>: the name of the column to cast values
925 <type>: one of 'number', 'bool', or 'date'.
926
927EXAMPLES
928 $ fauna import --path ./collection_name.csv
929 $ fauna import --append --path ./collection.csv
930 $ fauna import --db=sampleDB --collection=SampleCollection --path ./datafile.csv
931 $ fauna import --db=sampleDB --path ./dump
932 $ fauna import --type=header_name::date --type=hdr2::number --type=hdrX::bool --path ./collection.csv
933```
934
935_See code: [src/commands/import.js](src/commands/import.js)_
936
937## `fauna upload-graphql-schema graphqlFilePath`
938
939Upload GraphQL schema
940
941```
942USAGE
943 $ fauna upload-graphql-schema GRAPHQLFILEPATH
944
945ARGUMENTS
946 GRAPHQLFILEPATH Path to GraphQL schema
947
948OPTIONS
949 --domain=domain Fauna server domain
950 --endpoint=endpoint Fauna server endpoint
951 --graphqlHost=graphqlHost The Fauna GraphQL API host
952 --graphqlPort=port GraphQL port
953 --mode=merge|override [default: merge] Upload mode
954 --port=port Connection port
955 --scheme=https|http Connection scheme
956 --secret=secret Fauna secret key
957 --timeout=timeout Connection timeout in milliseconds
958
959EXAMPLES
960 $ fauna upload-graphql-schema ./schema.gql
961 $ fauna upload-graphql-schema ./schema.gql --mode override
962```
963
964_See code: [src/commands/upload-graphql-schema.js](https://github.com/fauna/fauna-shell/blob/v0.9.9/src/commands/upload-graphql-schema.js)_
965
966## `fauna import --path FILE_PATH`
967
968Import data to dana
969
970```
971USAGE
972 $ fauna import --path FILE_PATH
973
974
975OPTIONS
976 --allow-short-rows Allows rows which are shorter than the number of headers
977 --append Allows appending documents to a non-empty collection
978 --collection=collection Collection name. When not specified, the collection name is the filename when --path is file
979 --db=db Child database name; imported documents are stored in this database
980 --domain=domain Fauna server domain
981 --endpoint=endpoint Fauna server endpoint
982 --path=path (required) Path to .csv/.json file, or path to folder containing .csv/.json files
983 --port=port Connection port
984 --scheme=https|http Connection scheme
985 --secret=secret Fauna secret key
986 --timeout=timeout Connection timeout in milliseconds
987
988 --type=type Column type casting, converts the column value to a Fauna type.
989 Format: <column>::<type>
990 <column>: the name of the column to cast values
991 <type>: one of 'number', 'bool', or 'date'.
992
993EXAMPLES
994 $ fauna import --path ./samplefile.csv
995 $ fauna import --append --path ./samplefile.csv
996 $ fauna import --db=sampleDB --collection=Samplecollection --path ./samplefile.csv
997 $ fauna import --db=sampleDB --path ./dump
998 $ fauna import --type=header_name::date --type=hdr2::number --type=hdrX::bool --path ./samplefile.csv
999```
1000
1001_See code: [src/commands/upload-graphql-schema.js](https://github.com/fauna/fauna-shell/blob/v0.9.9/src/commands/upload-graphql-schema.js)_
1002
1003<!-- commandsstop -->
1004
1005# Development
1006
1007All above commands starts with `fauna`, but you are able to run them this way after installation of the fauna-shell package.
1008During development, you might want to test your changes without installing the package every single time.
1009To do so, you can run commands like this:
1010
1011```
1012# don't forget to install dependencies for your fauna-shell project
1013npm install
1014
1015# run a command you need
1016./bin/run cloud-login
1017./bin/run import
1018```