【问题标题】:Google Cloud DataStore GQL谷歌云数据存储 GQL
【发布时间】:2018-01-30 07:40:41
【问题描述】:

我正在为 NODEJS 上的水线开发适配器,我正在实现接口适配器,但在描述谷歌云数据存储的架构时遇到问题,我需要获取一种属性列表,但我不知道如何获得属性。我已经尝试过这个 SQL,但只有我得到了没有属性的种类。

select __key__ from __kind__ 

在 GQL 上相当于 Mysql 的描述如何?

谢谢

【问题讨论】:

    标签: gql


    【解决方案1】:

    对于任何想要获取一种类型的所有属性的人来说,查询非常简单。接下来的代码是种类的例子,种类的名称是Task。

    创建种类的例子

    const kind = 'Task';
    const name = '100';
    
    const taskKey = datastore.key([kind, name]);
    
    const task = {
      key: taskKey,
      data: {
        description: 'not more tasks',
      }
    };
    
    datastore
      .save(task)
      .then(() => {
        console.log('the creation ends fine');
      })
      .catch(err => {
        console.error('ERROR:', err);
      });
    

    返回种类属性的查询示例

    select * from __Stat_PropertyName_Kind__ where kind_name = 'Task'
    

    返回并打印一种属性的 NODEJS 代码示例

    const query = datastore
          .createQuery('__Stat_PropertyName_Kind__')
          .filter('kind_name', '=', 'Task');
    
    datastore.runQuery(query).then(results => {
            var response = results[0];
            var schema = response[0];
            console.log(schema.kind_name);
            console.log(schema.property_name);
        });
    

    查询的结果如下: 任务 说明

    【讨论】:

      猜你喜欢
      • 2019-07-30
      • 2015-07-17
      • 1970-01-01
      • 2017-05-11
      • 1970-01-01
      • 2018-10-11
      • 2013-11-24
      • 2019-01-15
      • 2018-01-18
      相关资源
      最近更新 更多