Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const { result, params, parsedQueryAttrs } = this.state;
if (report) {
const someQueryAttrChanged = report.tx_data
.map(({a}) => a)
.some(a => parsedQueryAttrs[a]);
//Did this last transaction not contain changes to any fields referenced
//by this query? Skip the re-query (and corresponding component update)
if (query && !someQueryAttrChanged) {
return;
}
}
if (query) {
const qArgs = [query, datascript.db(this.conn)];
if (params) {
qArgs.push(params);
}
if (rules) {
qArgs.push(rules);
}
let queryResult = datascript.q(...qArgs);
this.setState({ result: queryResult || this.state.result });
return;
}
if (pull) {
const { entityIds } = this.props;
let queryResult = datascript.pull_many(datascript.db(this.conn), pull, entityIds);
this.setState({ result: queryResult || this.state.result });
return;