I would like to play with those features, is there a quick guide I can follow so I can play with those features? For GraphQL I can probably follow the thread above.
GraphQL is not yet ready to be included into main source tree. But I think it would be soon. I need to address the naming problem first. For now you may try experimental binary (build from #449) or Docker version from original post.
Regarding types, you can just import the data and that’s it - you are already using them! The only difference you may notice with unmodified dataset - it’s the presence of IRIs (nodes with <>). Old importer drops type information, thus
<bob> became the same node. Now they are separate, so you’ll need to change your queries accordingly.
For example, with data:
<bob> <name> "Bob" . <bob> <follows> <fred>
Old query looks like this:
The new one will be:
For more context of why it’s necessary you might want to check Types from JS.
But it’s not the end of the story, you can do more interesting things with types. You can modify the dataset to include more type information. Most of examples how it can be done can be found in RDF concepts. In short, typed values are expressed in this way in nquads:
Meaning we have value
"10" of type
All other values are treated as opaque and will be saved without any changes.
Now, what can you do with those types?
First of all, Cayley will now preserve any (even unknown) type information you write. This is useful if you use Cayley as a library, because now it’s not necessary to encode and decode data that is passed to the database.
Comparison operation is available for types described above. This means range queries can now be written without additional JS code. Simple range query will look like this:
g.V().Filter( gt(10), lte(15) ).All() // all nodes > 10 and <= 15
Only few operators are supported for now:
Gremlin interoperability is also improved. For example, JS numbers and dates are automatically converted to their RDF analogs, this means you don’t need to write the whole
'"10"^^<http://schema.org/Integer>' thing as value in JS, simply
10 will work. You can alternatively force a specific type for a value with helpers:
raw("bob") // assumes value is already nquad-escaped; will not be modified by database at all iri("bob") // becomes <bob> (IRI) in nquads bnode("bob") // becomes _:bob (blank node) in nquads str("<html>") // becomes "<html>" (string literal) lang("Bob","en") // language-annotated string "Bob"@en typed("10","xsd:integer") // type-annotated value "10"^^<xsd:integer>
But in any case, usage of all of these features depends on the schema of your application.
RFHT: Date Range Searching
Thanks for the detailed reply!
Do date types currently support the comparison operators? Meaning, can I get back all the nodes with the predicate of “added_on” between X date and Y date?
Sure, it should work.