@__path/graph 中文文档教程

发布于 4年前 浏览 26 项目主页 更新于 3年前

Installation

导航到您的项目文件夹后,运行:

$ yarn add @__path/graph

或:

$ npm install @__path/graph --save

用法示例:

import { Graph } from "@__path/graph";

let graph = new Graph("/graph-path"); //the root instance

let Author = new Graph()
  .Service("Author") //service can created using "./__path create controller <ServiceName> --graph"
  .fetchAll("name"); //column to fetch, can be Graph.Column('name')

let posts = graph.Service("Blog").fetchAll(
  Graph.Column("title"),
  Graph.Column("author_id"),
  Author.As("author"), //fetch Author instance(Service) as author(key)
  Graph.Column("body")
);

posts.get().then((res) => console.log(res));

/*
* [
  {
    "title": "Hello title",
    "author_id": 1,
    "author": {
      "name": "Adewale"
    }
  }
]
* */

Installation

After navigating into your project folder, Run:

$ yarn add @__path/graph

or:

$ npm install @__path/graph --save

Usage Example:

import { Graph } from "@__path/graph";

let graph = new Graph("/graph-path"); //the root instance

let Author = new Graph()
  .Service("Author") //service can created using "./__path create controller <ServiceName> --graph"
  .fetchAll("name"); //column to fetch, can be Graph.Column('name')

let posts = graph.Service("Blog").fetchAll(
  Graph.Column("title"),
  Graph.Column("author_id"),
  Author.As("author"), //fetch Author instance(Service) as author(key)
  Graph.Column("body")
);

posts.get().then((res) => console.log(res));

/*
* [
  {
    "title": "Hello title",
    "author_id": 1,
    "author": {
      "name": "Adewale"
    }
  }
]
* */
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文