Hi,
i have some kind of the following schema to version some data:
firstName: string @index(fulltext) .
nodes: [uid] @reverse .
txAt: dateTime .
delete: bool @index(bool).
firstNames: [uid] @reverse .
type Tx {
txAt: dateTime
nodes: [uid]
delete: bool
}
type User {
firstNames: [uid]
}
type FirstName {
firstName: string
}
the following query has the expected result:
query{
users(func: type(User)){
uid
firstNames {
firstName
tx: ~nodes {
delete
txAt
}
}
}
example result:
"users": [
{
"uid": "0x76db",
"firstNames": [
{
"firstName": "Marcus",
"tx": [
{
"delete": false,
"txAt": "2020-01-10T10:04:05.129457683Z"
},
{
"delete": true,
"txAt": "2020-01-11T08:04:05.131234323Z"
}
]
},
{
"firstName": "Markus",
"tx": [
{
"delete": false,
"txAt": "2020-01-10T11:04:05.123456789Z"
}
]
}
]
}
]
- Question:
Since one could not use something like @filter(eq(firstNames.tx.delete, false) on the āparentā- Node because you could not drill into the array and subelements
how can you filter out the deleted data?
IĀ“m new to draph Queries and tried some stuff with @cascade and var, but iĀ“m stuck.
Wanted result is just the firstname āMarkusā. Example:
"users": [
{
"uid": "0x76db",
"firstNames": [
{
"firstName": "Markus",
"tx": [
{
"delete": false,
"txAt": "2020-01-10T11:04:05.123456789Z"
}
]
}
]
}
]
- Could you optimize this further to the following output (only fetch the first Element of the array āfirstNamesā and alias it/convert it to an object instead of an array Element?
"users": [
{
"uid": "0x76db",
"firstName": "Markus"
}
]