标签:docke col pos src tab href services drop link
使用docker-compose 运行
version: "3"
services:
db:
image: edgedb/edgedb
ports:
- "5656:5656"
- "8888:8888"
进入容器
按照提下提示操作
edgedb --admin alter role edgedb --password
CREATE DATABASE tutorial;
\c tutorial
数据库schema 定义语言
START TRANSACTION;
CREATE MIGRATION movies TO {
type Movie {
required property title -> str;
# the year of release
property year -> int64;
required link director -> Person;
multi link cast -> Person;
}
type Person {
required property first_name -> str;
required property last_name -> str;
}
};
COMMIT MIGRATION movies;
?
COMMIT;
效果
START TRANSACTION;
START TRANSACTION
edgedb> CREATE MIGRATION movies TO {
CREATE MIGRATION
edgedb> COMMIT MIGRATION movies;
COMMIT MIGRATION
edgedb> COMMIT;
COMMIT TRANSACTION
可选的sdl 方式
CREATE TYPE Person {
CREATE REQUIRED PROPERTY first_name -> str;
CREATE REQUIRED PROPERTY last_name -> str;
};
CREATE TYPE Movie {
CREATE REQUIRED PROPERTY title -> str;
# the year of release
CREATE PROPERTY year -> int64;
CREATE REQUIRED LINK director -> Person;
CREATE MULTI LINK cast -> Person;
};
INSERT Movie {
title := ‘Blade Runner 2049‘,
year := 2017,
director := (
INSERT Person {
first_name := ‘Denis‘,
last_name := ‘Villeneuve‘,
}
),
cast := {
(INSERT Person {
first_name := ‘Harrison‘,
last_name := ‘Ford‘,
}),
(INSERT Person {
first_name := ‘Ryan‘,
last_name := ‘Gosling‘,
}),
(INSERT Person {
first_name := ‘Ana‘,
last_name := ‘de Armas‘,
}),
}
};
效果
{Object { id: <uuid>‘66807bcc-5e05-11e9-a37c-2fb9bd2b9a50‘ }}
INSERT Movie {
title := ‘Dune‘,
director := (
SELECT Person
FILTER
# the last name is sufficient
# to identify the right person
.last_name = ‘Villeneuve‘
)
};
select Movie;
效果
select Movie;
{
Object { id: <uuid>‘66807bcc-5e05-11e9-a37c-2fb9bd2b9a50‘ },
Object { id: <uuid>‘ae442d8c-5e05-11e9-a37c-cfe0a3967be9‘ }
}
SELECT Movie {
title,
year
};
效果
SELECT Movie {
{Object { title: ‘Blade Runner 2049‘, year: 2017 }, Object { title: ‘Dune‘, year: {} }}
?
SELECT Movie {
title,
year
}
FILTER .title ILIKE ‘blade runner%‘;
效果
SELECT Movie {
{Object { title: ‘Blade Runner 2049‘, year: 2017 }}
ALTER TYPE Person {
ALTER PROPERTY first_name {
DROP REQUIRED;
}
};
注意需要在数据库中操作,先连接数据库 \c tutorial
CONFIGURE SYSTEM INSERT Port {
protocol := "graphql+http",
database := "tutorial",
address := "0.0.0.0",
port := 8888,
user := "http",
concurrency := 4,
};
效果
tutorial> CONFIGURE SYSTEM INSERT Port {
CONFIGURE SYSTEM
http://localhost:8888/explore
query {
Movie {
director {
id
last_name
first_name
}
id
cast {
id
last_name
first_name
}
title
year
}
}
edgedb schema 定义的地方以及查询上有好多地方和graphql 规范很相近,同时保留了sql 强大的能力,还是很不错的,但是目前的
client sdk 还是有点少
https://edgedb.com/docs/intro
https://hub.docker.com/r/edgedb/edgedb
https://github.com/edgedb/edgedb
标签:docke col pos src tab href services drop link
原文地址:https://www.cnblogs.com/rongfengliang/p/10703739.html