Giter Club home page Giter Club logo

Comments (5)

hoijnet avatar hoijnet commented on June 24, 2024

Good find. The documentation mentions both triple and quad forms for this query. I think this is a bug indeed, or a client issue. For others seeing this later, check the documentation and use the quad style for now, but there are situations where there are many operations in the schema that really needs the from style!

Great catch @alexander-mart

from terminusdb.

GavinMendelGleason avatar GavinMendelGleason commented on June 24, 2024

This is a client bug, the generated JSON is:

{"@type":"Limit","limit":10,
  "query":{"@type":"And",
  "and":[{"@type":"From"},
              {"@type":"Triple",
               "subject":{"@type":"NodeValue","variable":"cls"},
               "predicate":{"@type":"NodeValue","node":"rdf:type"},
               "object":{"@type":"Value","node":"sys:Class"}}]}} 

Fluent syntax apparently does not work here, You can use the two argument call to from for now, and we can fix the documentation, but it would probably be nice if the fluent syntax worked to generate the right code here.

from terminusdb.

hoijnet avatar hoijnet commented on June 24, 2024

I'd like to just check my understanding so that I interpret the fluent style correctly, the fluent style continuation is from my understanding always an extra appended parameter to the argument list? I was thinking about this for the WOQL-TS client and what was the correct interpretation.

Should thus the below be what should be in the doc link?

let v = Vars("cls");
from("schema", WOQL.triple(v.cls, "rdf:type", "sys:Class"))

With triple being the last argument of from()

from terminusdb.

alexander-mart avatar alexander-mart commented on June 24, 2024

With triple being the last argument of from()

Yes, for example convention in Ramda (Functional Programming JS-library):

The primary distinguishing features of Ramda are:

  • Ramda emphasizes a purer functional style. Immutability and side-effect free functions are at the heart of its design philosophy. This can help you get the job done with simple, elegant code.
  • Ramda functions are automatically curried. This allows you to easily build up new functions from old ones simply by not supplying the final parameters.
  • The parameters to Ramda functions are arranged to make it convenient for currying. The data to be operated on is generally supplied last.

The last two points together make it very easy to build functions as sequences of simpler functions, each of which transforms the data and passes it along to the next. Ramda is designed to support this style of coding.

Source: https://ramdajs.com/

How is currying work:

These queries should be identical (if from() function was curried):

let v = Vars("cls");
from("schema", WOQL.triple(v.cls, "rdf:type", "sys:Class"))
let v = Vars("cls");
from("schema").triple(v.cls, "rdf:type", "sys:Class")

from terminusdb.

alexander-mart avatar alexander-mart commented on June 24, 2024

Good find. The documentation mentions both triple and quad forms for this query. I think this is a bug indeed, or a client issue. For others seeing this later, check the documentation and use the quad style for now, but there are situations where there are many operations in the schema that really needs the from style!

Great catch @alexander-mart

For those who are looking for a solution 👍
For now, please use:

WOQL.quad("v:cls", "rdf:type", "sys:Class", "schema")

See: https://terminusdb.com/docs/javascript/#fromgraphrefquery

Instead of

from("schema", triple("v:cls", "rdf:type", "sys:Class"))

from terminusdb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.