zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    Java-单机版的书店管理系统(练习设计模块和思想_系列 二 )
    HDOJ 1279 验证角谷猜想
    HDOJ 1266 Reverse Number(数字反向输出题)
    lucas定理
    CRT && exCRT模板
    exgcd模板
    洛谷P4774 屠龙勇士
    洛谷P1477 假面舞会
    洛谷P2704 炮兵阵地
    CF1080
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/10694142.html
Copyright © 2011-2022 走看看