1 | # fauna-shell
|
2 |
|
3 |
|
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 |
|
10 | This tools gives you access to [Fauna](http://fauna.com/) directly from your CLI.
|
11 |
|
12 | It also includes a [Shell](#shell) so you can issue queries to Fauna without needing to install additional libraries.
|
13 |
|
14 | You can install it via npm like this:
|
15 |
|
16 | ```sh-session
|
17 | $ npm install -g fauna-shell
|
18 | ```
|
19 |
|
20 |
|
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 |
|
32 |
|
33 | # Usage
|
34 |
|
35 | The **fauna-shell** allows you to do things like _creating_, _deleting_ and _listings_ databases.
|
36 |
|
37 | First 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 |
|
39 | Let's run the following command:
|
40 |
|
41 | ```sh-session
|
42 | $ fauna cloud-login
|
43 | ```
|
44 |
|
45 | You will be prompted for your `email` and `password` from your [Fauna](https://dashboard.fauna.com) account.
|
46 |
|
47 | If 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 |
|
49 | Now 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 |
|
51 | This is how you can create a database called `my_app`:
|
52 |
|
53 | ```sh-session
|
54 | $ fauna create-database my_app
|
55 | creating database my_app
|
56 |
|
57 | created database my_app
|
58 |
|
59 | To start a shell with your new database, run:
|
60 |
|
61 | fauna shell my_app
|
62 |
|
63 | Or, to create an application key for your database, run:
|
64 |
|
65 | fauna create-key my_app
|
66 | ```
|
67 |
|
68 | And then listing your databases:
|
69 |
|
70 | ```sh-session
|
71 | $ fauna list-databases
|
72 | listing databases
|
73 | my_app
|
74 | my_second_app
|
75 | my_other_app
|
76 | ```
|
77 |
|
78 | You can also delete a particular database:
|
79 |
|
80 | ```sh-session
|
81 | $ fauna delete-database my_other_app
|
82 | deleting database 'my_other_app'
|
83 | database 'my_other_app' deleted
|
84 | ```
|
85 |
|
86 | You can also `create`, `list`, and `delete` _keys_.
|
87 |
|
88 | This is how you create a key for the database `my_app`:
|
89 |
|
90 | ```sh-session
|
91 | $ fauna create-key my_app
|
92 | creating key for database 'my_app' with role 'admin'
|
93 |
|
94 | created key for database 'my_app' with role 'admin'.
|
95 | secret: ****************************************
|
96 |
|
97 | To access 'my_app' with this key, create a client using
|
98 | the driver library for your language of choice using
|
99 | the above secret.
|
100 | ```
|
101 |
|
102 | This is how to list keys (the results may differ from what you see in your database)
|
103 |
|
104 | ```sh-session
|
105 | $ fauna list-keys
|
106 | listing keys
|
107 | Key ID Database Role
|
108 | 203269476002562560 my_app admin
|
109 | 203269731203940864 my_app admin
|
110 | 203269732275585536 my_app admin
|
111 | 203269735610057216 test admin
|
112 | ```
|
113 |
|
114 | And then delete the key with id: `200219702370238976`:
|
115 |
|
116 | ```sh-session
|
117 | $ fauna delete-key 200219702370238976
|
118 | deleting key 200219702370238976
|
119 | key 200219702370238976 deleted
|
120 | ```
|
121 |
|
122 | See [Commands](#commands) for a list of commands and help on their usage.
|
123 |
|
124 | # Technical Requirements
|
125 |
|
126 | In 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 |
|
135 | By 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 |
|
137 | For example:
|
138 |
|
139 | ```bash
|
140 | FAUNA_SHELL_LOGIN_URL=https://www.mycustomdomain.com/login
|
141 | ```
|
142 |
|
143 | # Shell
|
144 |
|
145 | The Fauna Shell lets you issue queries directly to your Fauna database without the need for installing additional libraries.
|
146 |
|
147 | Let'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 |
|
153 | Our 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
|
157 | Starting shell for database my_app
|
158 | Connected to http://127.0.0.1:8443
|
159 | Type Ctrl+D or .exit to exit the shell
|
160 | my_app>
|
161 | ```
|
162 |
|
163 | Once 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
|
166 | my_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 |
|
176 | Let's create an index for our collection `Post`.
|
177 |
|
178 | ```javascript
|
179 |
|
180 | my_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 |
|
200 | Let's insert a new `Post` document:
|
201 |
|
202 | ```javascript
|
203 | my_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 |
|
212 | We can also insert items in bulk by using iterator functions on arrays.
|
213 |
|
214 | ```javascript
|
215 | my_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 |
|
238 | Now let's try to fetch our post about _latte_. We need to access it by _id_ like this:
|
239 |
|
240 | ```javascript
|
241 | my_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 |
|
250 | Now let's update our post about our cat, by adding some tags:
|
251 |
|
252 | ```javascript
|
253 | my_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 |
|
266 | And now let's try to change the content of that post:
|
267 |
|
268 | ```javascript
|
269 | my_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 |
|
278 | Now let's try to delete our post about _latte_:
|
279 |
|
280 | ```javascript
|
281 | my_app> Post.byId("373143473420763648")!.delete()
|
282 | Post.byId("373143473420763648") /* not found */
|
283 | ```
|
284 |
|
285 | If we try to fetch it, we will receive a null document:
|
286 |
|
287 | ```javascript
|
288 | my_app> Post.byId("373143473420763648")
|
289 | Post.byId("373143473420763648") /* not found */
|
290 | ```
|
291 |
|
292 | Finally you can exit the _shell_ by pressing `ctrl+d`.
|
293 |
|
294 | # Command Details
|
295 |
|
296 |
|
297 |
|
298 | ```sh-session
|
299 | $ fauna COMMAND
|
300 | running command...
|
301 | $ fauna (-v|--version|version)
|
302 | fauna/0.0.1 darwin-x64 node-v8.11.1
|
303 | $ fauna --help [COMMAND]
|
304 | USAGE
|
305 | $ fauna COMMAND
|
306 | ...
|
307 | ```
|
308 |
|
309 | # Connecting to different endpoints
|
310 |
|
311 | We 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"
|
315 | Endpoint Key: ****************************************
|
316 | Endpoint Alias [example.com]: example_alias
|
317 | ```
|
318 |
|
319 | The _Endpoint Alias_ should be a name that helps you remember the purpose of this endpoint.
|
320 |
|
321 | If 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 |
|
327 | The _default endpoint_ will be used by the shell to connect to Fauna if the `--endpoint` flag is not set.
|
328 |
|
329 | Endpoints can be listed with the `list-endpoints` command like this:
|
330 |
|
331 | ```sh-session
|
332 | $ fauna list-endpoints
|
333 | localhost
|
334 | cloud *
|
335 | cluster-us-east
|
336 | ```
|
337 |
|
338 | There we see that the `cloud` endpoint has a `*` next to its name, meaning that it's the current default one.
|
339 |
|
340 | Finally, endpoints will be saved to a `~/.fauna-shell` file like this:
|
341 |
|
342 | ```ini
|
343 | default=cloud
|
344 |
|
345 | [localhost]
|
346 | domain=127.0.0.1
|
347 | port=8443
|
348 | scheme=http
|
349 | secret=secret
|
350 | graphqlHost=127.0.0.1
|
351 | graphqlPort=8084
|
352 |
|
353 |
|
354 | [cloud]
|
355 | domain=db.fauna.com
|
356 | scheme=https
|
357 | secret=FAUNA_SECRET_KEY
|
358 | graphqlHost=graphql.fauna.com
|
359 | graphqlPort=443
|
360 |
|
361 | [cluster-us-east]
|
362 | domain=cluster-us-east.example.com
|
363 | port=443
|
364 | scheme=https
|
365 | secret=OTHER_FAUNA_SECRET
|
366 | graphqlHost=cluster-us-east.example.com
|
367 | graphqlPort=443
|
368 | ```
|
369 |
|
370 | # Connecting to local endpoints
|
371 |
|
372 | If 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 |
|
374 | Once you've installed the Shell and logged in, you can configure this by doing the following:
|
375 |
|
376 | 1. 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 |
|
378 | 2. 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
|
381 | fauna add-endpoint http://localhost:8443 # Doesn't work with HTTPS
|
382 | ```
|
383 |
|
384 | 3. When prompted, provide the endpoint key and then give it a name (ex. `localhost`)
|
385 |
|
386 | 4. Now, you can interact with your local database through the Fauna Shell by running the command below:
|
387 |
|
388 | ```bash
|
389 | fauna shell --endpoint localhost
|
390 | ```
|
391 |
|
392 | # Overriding Connection Parameters
|
393 |
|
394 | Most commands support the following options. You can specify them if you want to connect to a local instance of Fauna.
|
395 |
|
396 | ```
|
397 | OPTIONS
|
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 |
|
408 | They 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 |
|
414 | Options provided via the CLI will override the values set in the `.fauna-shell` config file.
|
415 |
|
416 | For 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 |
|
422 | Any 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 |
|
426 | You 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
|
429 | Collection.create({
|
430 | name: "Post",
|
431 | indexes: {
|
432 | byTitle: {
|
433 | terms: [{ field: ".title" }]
|
434 | }
|
435 | }
|
436 | })
|
437 | ```
|
438 |
|
439 | Once the collection is created, you can execute queries against it in another `.fql` file:
|
440 |
|
441 | ```
|
442 | Post.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 |
|
457 | You 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 |
|
464 | Where `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 |
|
467 |
|
468 | # List of Commands
|
469 |
|
470 |
|
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 |
|
506 | Adds a connection endpoint for Fauna.
|
507 |
|
508 | ```
|
509 | USAGE
|
510 | $ fauna add-endpoint ENDPOINT
|
511 |
|
512 | ARGUMENTS
|
513 | ENDPOINT Fauna server endpoint
|
514 |
|
515 | DESCRIPTION
|
516 | Adds a connection endpoint for Fauna.
|
517 |
|
518 | EXAMPLE
|
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 |
|
527 | display autocomplete installation instructions
|
528 |
|
529 | ```
|
530 | USAGE
|
531 | $ fauna autocomplete [SHELL]
|
532 |
|
533 | ARGUMENTS
|
534 | SHELL shell type
|
535 |
|
536 | OPTIONS
|
537 | -r, --refresh-cache Refresh cache (ignores displaying instructions)
|
538 |
|
539 | EXAMPLES
|
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 |
|
550 | Adds a Fauna endpoint.
|
551 |
|
552 | ```
|
553 | USAGE
|
554 | $ fauna cloud-login
|
555 |
|
556 | DESCRIPTION
|
557 | Adds a Fauna endpoint.
|
558 |
|
559 | EXAMPLE
|
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 |
|
567 | Creates a database
|
568 |
|
569 | ```
|
570 | USAGE
|
571 | $ fauna create-database DBNAME
|
572 |
|
573 | ARGUMENTS
|
574 | DBNAME database name
|
575 |
|
576 | OPTIONS
|
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 |
|
584 | DESCRIPTION
|
585 | Creates a database
|
586 |
|
587 | EXAMPLE
|
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 |
|
595 | Creates a key for the specified database
|
596 |
|
597 | ```
|
598 | USAGE
|
599 | $ fauna create-key DBNAME [ROLE]
|
600 |
|
601 | ARGUMENTS
|
602 | DBNAME database name
|
603 | ROLE (admin|server|server-readonly|client) key user role
|
604 |
|
605 | OPTIONS
|
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 |
|
613 | DESCRIPTION
|
614 | Creates a key for the specified database
|
615 |
|
616 | EXAMPLE
|
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 |
|
624 | Sets an endpoint as the default one
|
625 |
|
626 | ```
|
627 | USAGE
|
628 | $ fauna default-endpoint ENDPOINT_ALIAS
|
629 |
|
630 | ARGUMENTS
|
631 | ENDPOINT_ALIAS Fauna server endpoint alias
|
632 |
|
633 | DESCRIPTION
|
634 | Sets an endpoint as the default one
|
635 |
|
636 | EXAMPLE
|
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 |
|
644 | Deletes a database
|
645 |
|
646 | ```
|
647 | USAGE
|
648 | $ fauna delete-database DBNAME
|
649 |
|
650 | ARGUMENTS
|
651 | DBNAME database name
|
652 |
|
653 | OPTIONS
|
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 |
|
661 | DESCRIPTION
|
662 | Deletes a database
|
663 |
|
664 | EXAMPLE
|
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 |
|
672 | Deletes a connection endpoint.
|
673 |
|
674 | ```
|
675 | USAGE
|
676 | $ fauna delete-endpoint ENDPOINT_ALIAS
|
677 |
|
678 | ARGUMENTS
|
679 | ENDPOINT_ALIAS Fauna server endpoint alias
|
680 |
|
681 | DESCRIPTION
|
682 | Deletes a connection endpoint.
|
683 |
|
684 | EXAMPLE
|
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 |
|
692 | Deletes a key
|
693 |
|
694 | ```
|
695 | USAGE
|
696 | $ fauna delete-key KEYNAME
|
697 |
|
698 | ARGUMENTS
|
699 | KEYNAME key name
|
700 |
|
701 | OPTIONS
|
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 |
|
709 | DESCRIPTION
|
710 | Deletes a key
|
711 |
|
712 | EXAMPLE
|
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 |
|
720 | display help for fauna
|
721 |
|
722 | ```
|
723 | USAGE
|
724 | $ fauna help [COMMAND]
|
725 |
|
726 | ARGUMENTS
|
727 | COMMAND command to show help for
|
728 |
|
729 | OPTIONS
|
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 |
|
737 | Lists child databases in the current database
|
738 |
|
739 | ```
|
740 | USAGE
|
741 | $ fauna list-databases
|
742 |
|
743 | OPTIONS
|
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 |
|
751 | DESCRIPTION
|
752 | Lists child databases in the current database
|
753 |
|
754 | EXAMPLE
|
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 |
|
762 | Lists connection endpoints.
|
763 |
|
764 | ```
|
765 | USAGE
|
766 | $ fauna list-endpoints
|
767 |
|
768 | DESCRIPTION
|
769 | Lists connection endpoints.
|
770 |
|
771 | EXAMPLE
|
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 |
|
779 | List keys in the current database or in its child databases
|
780 |
|
781 | ```
|
782 | USAGE
|
783 | $ fauna list-keys
|
784 |
|
785 | OPTIONS
|
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 |
|
793 | DESCRIPTION
|
794 | List keys in the current database or in its child databases
|
795 |
|
796 | EXAMPLE
|
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 |
|
804 | Runs the queries found on the file passed to the command.
|
805 |
|
806 | ```
|
807 | USAGE
|
808 | $ fauna run-queries DBNAME
|
809 |
|
810 | ARGUMENTS
|
811 | DBNAME database name
|
812 |
|
813 | OPTIONS
|
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 |
|
822 | DESCRIPTION
|
823 | Runs the queries found on the file passed to the command.
|
824 |
|
825 | EXAMPLE
|
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 |
|
833 | Starts an interactive shell.
|
834 |
|
835 | ```
|
836 | USAGE
|
837 | $ fauna shell [DBNAME]
|
838 |
|
839 | ARGUMENTS
|
840 | DBNAME database name
|
841 |
|
842 | OPTIONS
|
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 |
|
851 | DESCRIPTION
|
852 | Starts an interactive shell.
|
853 |
|
854 | EXAMPLE
|
855 | $ fauna shell dbname
|
856 | ```
|
857 |
|
858 | _See code: [src/commands/shell.js](src/commands/shell.js)_
|
859 |
|
860 | ## `fauna eval [DBNAME] [QUERY]`
|
861 |
|
862 | Evaluates a fauna query
|
863 |
|
864 | ```
|
865 | USAGE
|
866 | $ fauna eval [DBNAME] [QUERY]
|
867 |
|
868 | ARGUMENTS
|
869 | QUERY FQL query to execute
|
870 | DBNAME Database name
|
871 |
|
872 | OPTIONS
|
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 |
|
885 | DESCRIPTION
|
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 |
|
890 | EXAMPLES
|
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 |
|
903 | Import data to Fauna
|
904 |
|
905 | ```
|
906 | USAGE
|
907 | $ fauna import --path [DATA]
|
908 |
|
909 | OPTIONS
|
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 |
|
927 | EXAMPLES
|
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 |
|
939 | Upload GraphQL schema
|
940 |
|
941 | ```
|
942 | USAGE
|
943 | $ fauna upload-graphql-schema GRAPHQLFILEPATH
|
944 |
|
945 | ARGUMENTS
|
946 | GRAPHQLFILEPATH Path to GraphQL schema
|
947 |
|
948 | OPTIONS
|
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 |
|
959 | EXAMPLES
|
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 |
|
968 | Import data to dana
|
969 |
|
970 | ```
|
971 | USAGE
|
972 | $ fauna import --path FILE_PATH
|
973 |
|
974 |
|
975 | OPTIONS
|
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 |
|
993 | EXAMPLES
|
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 |
|
1004 |
|
1005 | # Development
|
1006 |
|
1007 | All above commands starts with `fauna`, but you are able to run them this way after installation of the fauna-shell package.
|
1008 | During development, you might want to test your changes without installing the package every single time.
|
1009 | To do so, you can run commands like this:
|
1010 |
|
1011 | ```
|
1012 | # don't forget to install dependencies for your fauna-shell project
|
1013 | npm install
|
1014 |
|
1015 | # run a command you need
|
1016 | ./bin/run cloud-login
|
1017 | ./bin/run import
|
1018 | ```
|