Skip to content

WOQL: Not able to query by selecting a particular document type using triple #193

@Neelterminusdb

Description

@Neelterminusdb

Describe the bug
I'm just creating documents and want to return them ordered by most recent first (descending by StartTime)

Here's the simple schema for the document:

{
  "@documentation": {
    "@comment": "Base memory",
    "@properties": {
      "Data": "The data representing the memory (only text right now)",
      "EndTime": "End time of memory",
      "StartTime": "Start time of memory"
    }
  },
  "@id": "Memory",
  "@key": { "@type": "Random" },
  "@type": "Class",
  "Data": "xsd:string",
  "EndTime": "xsd:dateTime",
  "StartTime": "xsd:dateTime"
}

The below query returns nothing (bindings is zero length array)

let qry = Q.triple("v:Memory", "type", "Memory").triple(
      "v:Memory",
      "Data",
      "v:Data"
    );

db.query(qry).then((response) => { yadda yadda}

I know documents are in there because i can get them with

db.getDocument({
         graph_type: "instance",
         as_list: true,
         type: "Memory",
         count: 20,
       })

The following was an attempt at orderying by StartTime, which also returns an emtpy binding array

let [StartTime] = Q.vars("StartTime");

    let qry = Q.order_by([StartTime, "asc"])
      .triple("v:Doc", "type", "Memory")
      .triple("v:Doc", "Data", "v:Message")
      .triple("v:Doc", "StartTime", StartTime);

    db.query(qry)

What's the proper syntax to get these documents returned ordered by newest first? (based on StartTime field)

Issue originally posted by community member Harman on discord

Metadata

Metadata

Labels

bugSomething isn't workingdocumentationImprovements or additions to documentationtriageissue to be triage

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions