Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to use some operators? #74

Open
Juravenator opened this issue Jul 27, 2016 · 1 comment
Open

how to use some operators? #74

Juravenator opened this issue Jul 27, 2016 · 1 comment

Comments

@Juravenator
Copy link

Juravenator commented Jul 27, 2016

I can't seem to use the contains() function, while others work just fine.
For example:

#!/usr/bin/node
var data = [
  {
    name: "first",
    number: 1,
    somearray: [
      "pizza",
      "nachos"
    ]
  },
  {
    name: "second",
    number: 2,
    somearray: [
      "fish",
      "chips"
    ]
  },
  {
    name: "third",
    number: 3,
    somearray: [
      "pizza",
      "chips"
    ]
  }
];

var queryFactory = require("rql/js-array").query;
var query = queryFactory("sort(-number)&number=gt=0&somearray=contains=chips");
var result = query(data);
console.log(result);

I can use "number=gt=0", "sort()", and "first()". But when I try to use contain it gives the following error:

node_modules/rql/js-array.js:66
            return array instanceof Array && contains(array, value);
                                             ^

TypeError: contains is not a function
    at node_modules/rql/js-array.js:66:37
    at Array.filter (node_modules/rql/js-array.js:301:7)
    at Array.eval (eval at query (node_modules/rql/js-array.js:419:73), <anonymous>:1:237)
    at Array.exports.operators.and (node_modules/rql/js-array.js:106:25)
    at Array.eval (eval at query (node_modules/rql/js-array.js:419:73), <anonymous>:1:58)
    at eval (eval at query (node_modules/rql/js-array.js:419:73), <anonymous>:1:274)
    at Object.<anonymous> (queryDemo.js:31:14)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)

I've tried to use "contains(somearray,chips)", and "somearray=contains=chips". Both give the same error.

Do these require a different syntax, or are these only supported in the new Query().lt("foo",3).gt("foo",10); fashion?

@Juravenator
Copy link
Author

The problem is the missing require("./util/contains") in js-array.js. When adding it, everything works normally.
commit 4ae84c8 has solved this, but this isn't included in a release yet.

Any ideas when a next release is planned?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant