How to use the datascript.db function in datascript

To help you get started, we’ve selected a few datascript examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gurdasnijor / react-datascript / src / withDatascriptQuery.js View on Github external
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;

datascript

Immutable in-memory triplestore with Datalog queries

EPL-1.0
Latest version published 4 months ago

Package Health Score

74 / 100
Full package analysis