HarperFast / HarperFast/rql

how to use some operators?

Open
#74 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
276
Forks
48
PR merge metrics
No merged PRs in 30d

Description

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

``` javascript
#!/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), :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), :1:58)
at eval (eval at query (node_modules/rql/js-array.js:419:73), :1:274)
at Object. (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?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.