edgedb 强大的对象关系数据库
edgedb 是一个强大的对象关系数据库,构建在pg 之上。
包含的特性:
- 严格的强类型模式;
- 强大而富有表现力的查询语言;
- 丰富的标准库;
- 内置支持模式迁移;
- 本机GraphQL支持。
数据模型
从表现上,类似graphql 的type 定义,如下:
type User {
required property name -> str;
}
type Person {
required property first_name -> str;
required property last_name -> str;
}
type Review {
required property body -> str;
required property rating -> int64 {
constraint min_value(0);
constraint max_value(5);
}
required link author -> User;
required link movie -> Movie;
required property creation_time -> local_datetime;
}
type Movie {
required property title -> str;
required property year -> int64;
required property description -> str;
multi link directors -> Person;
multi link cast -> Person;
property avg_rating := math::mean(.<movie[IS Review].rating);
}
edgeql
类似sql,但是很强大
SELECT User {
id,
name,
image,
latest_reviews := (
WITH UserReviews := User.<author
SELECT UserReviews {
id,
body,
rating,
movie: {
id,
title,
avg_rating,
}
}
ORDER BY .creation_time DESC
LIMIT 10
)
}
FILTER .id = <uuid>$id
graphql 支持
需要进行开启
CONFIGURE SYSTEM INSERT Port {
protocol := "graphql+http",
database := "tutorial",
address := "127.0.0.1",
port := 8888,
user := "http",
concurrency := 4,
};
查询方法:
{
Movie {
title
year
}
}
参考资料
https://edgedb.com/blog/edgedb-1-0-alpha-1/
https://github.com/edgedb/edgedb