Skip to content

how to use some operators? #74

Description

@Juravenator

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions