Git Product home page Git Product logo

edgedb-cli's Introduction

EdgeDB

Stars license discord

Quickstart   •   Website   •   Docs   •   Playground   •   Blog   •   Discord   •   Twitter



What is EdgeDB?

EdgeDB is a new kind of database
that takes the best parts of
relational databases, graph
databases, and ORMs. We call it
a graph-relational database.



🧩 Types, not tables 🧩


Schema is the foundation of your application. It should be something you can read, write, and understand.

Forget foreign keys; tabular data modeling is a relic of an older age, and it isn't compatible with modern languages. Instead, EdgeDB thinks about schema the same way you do: as object types containing properties connected by links.

type Person {
  required name: str;
}

type Movie {
  required title: str;
  multi actors: Person;
}

This example is intentionally simple, but EdgeDB supports everything you'd expect from your database: a strict type system, indexes, constraints, computed properties, stored procedures...the list goes on. Plus it gives you some shiny new features too: link properties, schema mixins, and best-in-class JSON support. Read the schema docs for details.


🌳 Objects, not rows 🌳


EdgeDB's super-powered query language EdgeQL is designed as a ground-up redesign of SQL. EdgeQL queries produce rich, structured objects, not flat lists of rows. Deeply fetching related objects is painless...bye, bye, JOINs.

select Movie {
  title,
  actors: {
    name
  }
}
filter .title = "The Matrix"

EdgeQL queries are also composable; you can use one EdgeQL query as an expression inside another. This property makes things like subqueries and nested mutations a breeze.

insert Movie {
  title := "The Matrix Resurrections",
  actors := (
    select Person
    filter .name in {
      'Keanu Reeves',
      'Carrie-Anne Moss',
      'Laurence Fishburne'
    }
  )
}

There's a lot more to EdgeQL: a comprehensive standard library, computed properties, polymorphic queries, with blocks, transactions, and much more. Read the EdgeQL docs for the full picture.


🦋 More than a mapper 🦋


While EdgeDB solves the same problems as ORM libraries, it's so much more. It's a full-fledged database with a powerful and elegant query language, a migrations system, a suite of client libraries in different languages, a command line tool, and—coming soon—a cloud hosting platform. The goal is to rethink every aspect of how developers model, migrate, manage, and query their database.

Here's a taste-test of EdgeDB's next-level developer experience: you can install our CLI, spin up an instance, and open an interactive EdgeQL shell with just three commands.

$ curl --proto '=https' --tlsv1.2 -sSf https://sh.edgedb.com | sh
$ edgedb project init
$ edgedb
edgedb> select "Hello world!"

Windows users: use this Powershell command to install the CLI.

PS> iwr https://ps1.edgedb.com -useb | iex

Get started

To start learning about EdgeDB, check out the following resources:

  • The quickstart. If you're just starting out, the 10-minute quickstart guide is the fastest way to get up and running.
  • EdgeDB Cloud 🌤️. The best most effortless way to host your EdgeDB database in the cloud.
  • The interactive tutorial. For a structured deep-dive into the EdgeQL query language, try the web-based tutorial— no need to install anything.
  • The e-book. For the most comprehensive walkthrough of EdgeDB concepts, check out our illustrated e-book Easy EdgeDB. It's designed to walk a total beginner through EdgeDB in its entirety, from the basics through advanced concepts.
  • The docs. Jump straight into the docs for schema modeling or EdgeQL!

Contributing

PRs are always welcome! To get started, follow this guide to build EdgeDB from source on your local machine.

File an issue 👉
Start a Discussion 👉
Join the discord 👉


License

The code in this repository is developed and distributed under the Apache 2.0 license. See LICENSE for details.

edgedb-cli's People

Contributors

1st1 avatar aljazerzen avatar ambv avatar cijiugechu avatar codesinchaos avatar colinhacks avatar dhghomon avatar diksipav avatar elprans avatar fantix avatar fmoor avatar fogapod avatar jaclarke avatar kaelwd avatar mirrorrim avatar mrfoxpro avatar msullivan avatar nsidnev avatar quinchs avatar raddevon avatar robertoprevato avatar scotttrinh avatar syzuna avatar tailhook avatar vpetrovykh avatar zackelan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

edgedb-cli's Issues

Discuss the UX of exposing CLI commands in REPL

This is related to #54.

We want to expose some of the useful CLI commands directly to the REPL. Dump, restore, and migrations are the first one that come to mind.

Do we want to expose ALL commands though? Should we mirror command arguments structure into the REPL?

No exit command or formatting

On EdgeDB 1.0-alpha.3+dev.198.g9e8c0613 I'm surprised to notice that exit and \q don't seem to work in the REPL, only ctrl+d does. Also my results are no longer nicely formatted and thus harder to read. +1 to bringing exit back and reverting to prettier results, please!

Limit max table width

We should do word-wrapping for overly long lines to makes sure tables are rendered nicely.

Screen Shot 2020-03-30 at 6 29 04 PM

The REPL command to set the query limit

Edgedb version: EdgeDB 1.0-alpha.3+dev.198.g9e8c0613
REPL version: edgedb-cli 0.1.0

Currently the command to set the query limit is \set limit, but the query results refer to \limit:

  '000000098',
  '000000099',
  ... (further results hidden \limit 100)
}

Ctrl+C during query execution quits REPL

Edgedb version: EdgeDB 1.0-alpha.3+dev.198.g9e8c0613
REPL version: edgedb-cli 0.1.0

If you press Ctrl+C during the SELECT sys::sleep(999) query, the REPL just quits. Considering that if the query isn't running, Ctrl+C simply aborts query input presenting a new prompt, this is unexpected.

(Same happens to other long-running queries, not just sleep)

Ideally it should attempt to cancel the query, but at the very least, quitting REPL should not happen. It might be a good idea to indicate what was done, too. In old REPL, I think the line became grayed-out, like a comment. We could do that. Also something as simple as just "echoing" Ctrl+C instead of the query result might also help, just to give a visual indication in case colors aren't available. A message like "Query cancelled" may be appropriate, but because this scenario is subject to the same race conditions as #40 perhaps we shouldn't imply anything about the status of the query on the server.

As far as I can tell the query still runs on the server even after Ctrl+C closes REPL and the REPL is restarted. Try this one:

CREATE TYPE Foo {CREATE PROPERTY val -> str};
INSERT Foo {val := <str>datetime_current() ++ <str>sys::sleep(20)};

Hit Ctrl+C before once the query starts. Re-enter REPL and try SELECT Foo{val} immediately and after 20 seconds.

@elprans is it possible to cancel the query? How many queries like that do I need to spam to severely impede the EdgeDB server (let's say I use sleep(999))? What (if anything) would fail in that case?

Add \h alias for \help & \?

I'm used to typing \h -- and while I personally can adjust I think that making it work would be a good UX.

Implement command-line semantics for backslash commands

In particular:

  • Semi-colon ; ends the command, but it's optional, newline ends too
  • \d xx yy is a command with two arguments, xx and yy not single xx yy as was previously
  • Flags are now dash prefixed:
    • S -> -s or --system
    • + -> -v or --versbose
    • I -> -I or --case-sensitive (but see #6 (comment))

\psql should use our postgres/bin, not the system one

yury> \psql
Error executing command: Error running "psql" "-h" "/Users/yury/.edgedb" "-U" "edgedb" "-p" "55043" "-d" "edgedb"

^ I don't have system postgres, so there's no psql command in my $PATH.

Our Python repl code does this to locate the psql we built as part of our vendored postgres:

        pg_config = buildmeta.get_pg_config_path()
        psql = pg_config.parent / 'psql'

Please find a way to replicate this functionality.

Make `edgedb restore` silent

Currently it outputs a bunch of stats:

Schema applied in 18.016791906s
Blocks sent in 5.529895ms
Complete in 18.045443671s
OK: RESTORE

REPL quits on attempting to connect to the wrong database

  • EdgeDB Version: 1.0-alpha.3+dev.223.gd5f5e87c
  • EdgeDB CLI Version: 0.1.0
  • OS Version: linux

Steps to Reproduce:

  1. In REPL try \c nope (or whatever other non-existing database).

Presumably we don't want to quit REPL on an exception, but rather say that there's no such database and remain in the currently valid one. It's a bit drastic to quit REPL on what amounts to, perhaps, a typo.

Feature request: ability to wait until database is ready to accept connections

Original post from spectrum: https://spectrum.chat/edgedb/general/a-way-to-wait-until-database-is-ready~0a96b827-26a1-4207-9f46-16cab8ac0068

Currently it seems like the only way to wait for edgedb is repeating requests during database bootstrapping until they succeed.
This is not the cleanest solution and is prone to errors.
My suggestion is to add wait subcommand for CLI tool that blocks until database is ready to accept connections.

REPL commands don't try re-connecting

  • EdgeDB Version: 1.0-alpha.3+dev.223.gd5f5e87c
  • EdgeDB CLI Version: 0.1.0
  • OS Version: linux

I have a weird corner case for re-connecting issues after a server restart. The following is produced after a restart:

db0> \d Object
Error executing command: end of stream
db0> \d Object
Error executing command: Broken pipe (os error 32)
db0> \d Object
Error executing command: Broken pipe (os error 32)
db0> DESCRIBE OBJECT Object;
Connection is broken. Reconnecting...
db0> DESCRIBE OBJECT Object;
{
  'CREATE ABSTRACT TYPE std::Object EXTENDING std::BaseObject {
    CREATE ANNOTATION std::description := \'Root object type for user-defined types\';
};',
}
db0> \d Object
abstract type std::Object extending std::BaseObject {
    required single link __type__ -> schema::Type {
        readonly := true;
    };
    required single property id -> std::uuid {
        readonly := true;
    };
};

Notice that the \d command doesn't handle reconnecting, only a "proper" command does.

This is related to #40 , since we probably ultimately want the same handling of re-connection.

Vim mode

This is mostly rustyline issue, but this issue tracks the status

  • dd and similar line commands should handle single line
  • visual selection mode

Re-try executing current buffer on broken connection

Currently, when the server goes away, REPL detects that and reconnects, but it doesn't execute the command I issued right away, which is annoying, because the dev cycle requires restarting the server frequently.

Display commands statuses

yury> CONFIGURE system insert Port {
.....   protocol := 'tutorial',
.....   database := 'yury',
.....   port := 3001,
.....   user := 'http',
.....   concurrency := 4,
..... };
WARNING: unsolicited message ReadyForCommand(ReadyForCommand { headers: {}, transaction_state: NotInTransaction })
  -> CONFIGURE SYSTEM: Ok

Allow to switch between different string rendering in REPL

There should be a command in REPL that allows switching between different string rendering (escaped vs. "as is") so that we don't lock the user into one mode for everything.

In my mind this seems analogous to \x in psql. Perhaps we might use that command.

REPL history commands

Edgedb version: EdgeDB 1.0-alpha.3+dev.198.g9e8c0613
REPL version: edgedb-cli 0.1.0

The \s command shows the history numbered with negative offsets. However the \e command doesn't appear to take negative offsets and takes positive line numbers instead. Unfortunately there's no simple way of actually getting the positive index of a given command.

To be clear, I prefer negative offset counting, and it would be natural to use the same numbering for \e command (if we have to chose only one).

Incidentally, can we control the history length? Maybe add a \set command for that, too?

victor> \e -1
Error parsing backslash command: Found argument '-1' which wasn't expected,
or isn't valid in this context

It also appears that the current session history gets lost when Ctrl+C kills the REPL (see issue #45), resetting back to the state before the last edgedb command was run. This is somewhat undesirable, as the same history loss happens if the REPL is simply killed. I would think that if something caused the REPL to die, it's quite useful to have the command history. I mean I haven't tried rebooting or crashing the computer in some other way as a "kill" mechanism, but I'm guessing that I'd lose my history then, too.

repl should count braces to determine end of input

yury> create type Foo {
.....    create property bar := (
.....       with a := 'aaa'
.....       select a ++ 'zzz'
.....    );                                         # <- I hit [ENTER]
error: Unexpected end of line
  ┌─ query:5:6
  │
5 │    );
  │      ^ error

The repl shouldn't have tried to execute the buffer until I typed }.

`edgedb dump` should accept connection args

The Python CLI accepts connections arguments after both edgedb and dump, with latter arguments overriding the former ones, e.g. all of the below do the same:

edgedb -d foo dump
edgedb dump -d foo
edgedb -d bar dump -d foo

This behavior of CLI command line isn't random -- we had a relatively involved discussion of this behavior in Slack.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.