Fork me on GitHub
#datascript
<
2017-02-10
>
bradford07:02:56

Hi! 2 questions. I'm using datascript to query arbitrarily complex JSON blobs (actually HAR archives like this: https://gist.github.com/LusciousPear/82f7b234ecbc6958b3c26b27539e839e), but I'm having trouble wrapping my head around nested entites: 1. How do I retrieve all {:response} where {:response :status} == 200 ? 2. How do I retireve all {:response} where {:response :headers []} contains 'Referer' ?

bradford08:02:35

3. Do I need to describe a schema up front? that would be p. painful because the objects are quite complex

rauh08:02:32

@bradford Yes you do. For attr -> value lookups you need the attribute to be indexed.

rauh08:02:51

Looks like an easy schema though, should be pretty straight forward. Note, you don't have types (like str/int) in datascript...

Niki08:02:59

datascript is not a good fit to query nested maps as they are. It can query flat collections though

Niki08:02:16

or, if you convert map into datascript database, you can query it then

bradford08:02:55

Ahhh. Thanks! Out of curiosity, is there something datascript-like that's good at querying nasty JSON blobs? I've tried to wrap my head around spectre but that's just not happening.

bradford08:02:08

(this is a simpler example)

Niki08:02:29

spectre is the only one I know. Never worked with it though, only know it matches the keywords :)

bradford08:02:59

I'm almost tempted to convert this to XML so I can use XPath. I know by doing that, I am excommunicated to some wretched, radioactive wasteland. 😉

bradford08:02:55

Although intension claims to play nice with DataScript. https://github.com/alandipert/intension