使用BaasBox进行NoSQL统计信息类型查询-OrientDB 1.7.10

安德鲁·格罗斯(Andrew Grothe)

我正在尝试与OrientDB 1.7.10一起提供的BaasBox v0.9.2,作为我要构建的概念证明Web应用程序。前提非常简单,添加/查询非常简单,对于单个集合很简单。我很难形象化的是如何在NoSQL中获取统计信息类型信息。

例如,我有一个联系人集合(名字,姓氏,地址等)和一个事件集合(标题,日期,时间等),每个事件都有一组参与者。

对象看起来像这样:

接触

{
  "firstName": "John",
  "lastName": "Doe",
  "appId": "64f00bcb-cc04-4ed9-89fc-3b9b1a448dae"
}

事件

{
  "title": "Some Event",
  "eventDate": "2015-02-24 04:46 PM",
  "isoDate": "2015-02-24T20:46:00.000Z",
  "appId": "64f00bcb-cc04-4ed9-89fc-3b9b1a448dae",
  "attendees": [
        {"contactId": "c8ae2767-5fe5-4d41-ad6a-b10bd6e62f03", "attended": true},
        {"contactId": "eacff8ff-b691-4d82-9429-898a097ea43a", "attended": true},
        {"contactId": "70ab166c-c0a0-488a-9d5f-6f0b70a32125", "attended": false},
        {"contactId": "34944c69-ebdb-49c6-bd1b-cdb0d191f124", "attended": true},
        {"contactId": "8907e99e-96d6-46e9-a76f-1f9ce7f760d3", "attended": true}
  ]
}

我想知道的是:

John Doe最近参加了什么活动?约翰·多伊(John Doe)错过了多少赛事?

我希望使用使用Baasbox JS-SDK的示例,但是Plugin-API也是可以接受的,因为没有任何困难,因此可以重新组织数据。

贾斯特法德

您可以使用OrientDB提供的任何运算符/功能http://www.orientechnologies.com/docs/1.7.8/orientdb.wiki/SQL-Where.html

在BaasBox中,可以将键“ fields”用于投影,将“ where”用于选择。因此,在您的情况下,代码应类似于:

BaasBox.loadCollectionWithParams("Event", 
        {
         fields:"max(eventDate) as last_date", //or count(*) as times
         where:"attendees contains (attended=true and contactId='<john_contact_id>')"
        })
        .done(function(res) {
                 console.log("res ", res);
        })
        .fail(function(error) {
                console.log("error ", error);
        });

REST API调用为:

GET /document/event?fields=max(eventDate) as last_date&where=attendees contains (attended=true and contactId='<john_contact_id>')

GET /document/event?fields=count(*) as times&where=attendees contains (attended=true and contactId='<john_contact_id>')

参考:

http://www.orientechnologies.com/docs/1.7.8/orientdb.wiki/SQL-Where.html

http://www.baasbox.com/documentation/?javascript#retrieve-documents通过查询段落检索文档

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

在OrientDB图上查询

来自分类Dev

查询OrientDB图

来自分类Dev

OrientDB 查询比较

来自分类Dev

OrientDB创建顶点类型

来自分类Dev

Orientdb中的类型转换

来自分类Dev

提取1至7和7-10记录

来自分类Dev

orientdb之类的使用节点js进行查询

来自分类Dev

使用OrientGraphFactory分发OrientDB

来自分类Dev

使用OrientDB的ShortestPath查询太慢

来自分类Dev

使用SimpleDateFormat解析10 ^ -7

来自分类Dev

OrientDB查询分层数据

来自分类Dev

OrientDB中查询的最佳索引

来自分类Dev

OrientDB的查询语言是什么?

来自分类Dev

OrientDB:连接的组件OSQL查询

来自分类Dev

在OrientDB中查询链接的顶点

来自分类Dev

OrientDB SELECT和子查询

来自分类Dev

OrientDB Traverse SQL查询效率

来自分类Dev

OrientDB选择查询而不是联接

来自分类Dev

Orientdb 超慢查询性能

来自分类Dev

元素1,6、7、10、13等的nth-child

来自分类Dev

OrientDB使用shortestPath()获得Edges

来自分类Dev

OrientDB-使用SUBSELECT更新

来自分类Dev

我想把数组 [1,2,3,4,5,6,7,8,9,10,11] 变成数组 [1,2,3,4,5,6,7,8,9,1 ,0,1,1] 仅使用此算法

来自分类Dev

OrientDB:如何使用选择查询更新列

来自分类Dev

使用OrientDB图形API与SQL查询的性能

来自分类Dev

使用 gremlin 查询更新 Orientdb 上的节点

来自分类Dev

Tomcat 7 上的 OrientDB JDBC 连接器池

来自分类Dev

使用Windows 7键激活Windows 10

来自分类Dev

如何在OrientDB中应用独特查询?