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

posted on   荣锋亮  阅读(470)  评论(0编辑  收藏  举报

编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2018-04-12 elixir grpc 试用
2018-04-12 elixir 调用erlang 代码
2018-04-12 Elixir's keyword lists as option parameters
2015-04-12 BigPipe 了解

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示