0

I am trying to create a view that joins user information from an external JSON source. At current I am investigating how to setup the entire view source myself, but I'm also investigating the views JSON source module, or views remote data as another means to achieve this

An example of the data from my source

  {
    "postId": 1,
    "uid": 1,
    "name": "id labore ex et quam laborum",
    "email": "[email protected]",
    "body": "laudantium enim quasi est quidem magnam voluptate ipsam eos\ntempora quo necessitatibus\ndolor quam autem quasi\nreiciendis et nam sapiente accusantium"
  },
  {
    "postId": 1,
    "uid": 2,
    "name": "quo vero reiciendis velit similique earum",
    "email": "[email protected]",
    "body": "est natus enim nihil est dolore omnis voluptatem numquam\net omnis occaecati quod ullam at\nvoluptatem error expedita pariatur\nnihil sint nostrum voluptatem reiciendis et"
  },
  {
    "postId": 1,
    "uid": 3,
    "name": "odio adipisci rerum aut animi",
    "email": "[email protected]",
    "body": "quia molestiae reprehenderit quasi aspernatur\naut expedita occaecati aliquam eveniet laudantium\nomnis quibusdam delectus saepe quia accusamus maiores nam est\ncum et ducimus et vero voluptates excepturi deleniti ratione"
  }
]

My source will contain a UID that will map to a Drupal account, but I've been having troubles setting up the relationship to handle this, partially because documentation is quite scarce, but any relationship handler I've setup following any documentation seems to fail saying the handler is broken, and I'm trying to understand if the relationship handler needs to be able to run a JOIN command against tables within the database, which it wouldn't have if one of the sources is external

In an ideal world I want to try to leverage views to do the majority of what it does naturally as I can, I'm intentionally trying to bring the data in via views so I can make use of relationships/filters/context without needing to code it into a module

Can the relationship only work if the tables are both present in the Drupal DB?

3
  • I don't have any experience using those modules. But in views a relationship is effectively a database JOIN so yes I'd imagine it's only going to work with tables in the DB Commented Jun 11 at 9:09
  • Alternate approach if you decide to ingest the data: You can create a custom entity type with a JSON Field, and then use Feeds Extensible Parsers to import the JSON from the external source (storing it in the JSON field). Commented Jun 12 at 8:03
  • @PatrickKenny I'd thought about ingesting it, but it's to bring in ever increasing amounts of analytical data, I'd considered either doing a timed synch or an import upon request for the data set, but I think there's inherent issues with either approach (mostly just due to the nature of the project) but I appreciate the suggestion Commented Jun 12 at 8:45

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.